# By 40 it's over 10^(100000)

**Computer Science**Level 4

A sequence of positive integers \(S\) with \(S_1=S_2=1\) is further defined by \(S_k=S_{k-1}\times S_{k-2}+1\) for \(k > 2.\)

The second time in the sequence that the last three digits of \(S_{n}\) will equal the last three digits of \(S_{n+1}\) will occur at \(S_{n=A},\) whose last three digits are \(B.\) Find \(A+B.\)

\(\textbf{Details and Assumptions}\)

The first time is the trivial case at \(S_{n=1}.\)

For example, if the last three digits of both \(S_{193}\) and \(S_{194}\) were both \(329,\) then \(A=193\) and \(B=329\) so the answer would be \(522.\)