OFFSET
1,2
REFERENCES
Terms computed by Bob Harder.
LINKS
Steven R. Finch, Periodicity in Sequences Mod 3 [Broken link]
Steven R. Finch, Periodicity in Sequences Mod 3 [From the Wayback machine]
EXAMPLE
For example, if n=4, then N=9, since the first 60 terms of x are:
0 0 0 1 1 1 1 2 0 1
2 0 0 1 2 2 2 0 1 2
0 0 1 2 2 2 0 1 2 0
0 1 2 2 2 0 1 2 0 0
1 2 2 2 0 1 2 0 0 1
2 2 2 0 1 2 0 0 1 2
MATHEMATICA
period[lst_List] := Catch[lg = If[Length[lst] <= 5, 2, 40]; lst1 = lst[[1 ;; lg]]; km = Length[lst] - lg; Do[ If[lst1 == lst[[k ;; k+lg-1]], Throw[k-1]]; If[k == km, Throw[0]], {k, 2, km}]]; a[n_] := (ClearAll[x]; x[i_ /; 1 <= i < n] = 0; x[n] = 1; x[i_] := x[i] = Mod[x[i-1] + x[i-n]^2, 3]; xx = Table[x[i], {i, 1, 20000}]; period[xx // Reverse]); Table[a[n], {n, 1, 59}] (* Jean-François Alcover, Nov 30 2012 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Dec 31 2005.
STATUS
approved