OFFSET
1,1
LINKS
Jean-François Alcover, Table of n, a(n) for n = 1..1000
MathOverflow, Mod sequences that seem to become constant
EXAMPLE
a(5) = 2, because the b sequence is 5, 1, 0, 2, 3, 5, 2, 2, 2, 2, 2, ...
MATHEMATICA
Clear[a]; constantLength = 10; kMax = 2000; a[n_] := a[n] = Module[{k}, Clear[b]; For[ b[1] = n; b[m_] := b[m] = Mod[Sum[b[j], {j, 1, m-1}], m]; k = constantLength, k <= kMax, k++, If[Equal @@ Table[b[k-j], {j, 0, constantLength-1}], Print["a(", n, ") = ", b[k], ", k = ", k - constantLength+1]; Return[b[k]]]]; Print["a(", n, ") = ", -1, ", k = ", k - constantLength+1, " constant run not found"]; Return[-1]]; Table[a[n], {n, 1, 100}]
CROSSREFS
KEYWORD
sign
AUTHOR
Jean-François Alcover, Dec 31 2014
STATUS
approved