A307087 a(n) is the number of steps it takes for the sequence f(0)=f(1)=n, f(x)=(a*b) mod (a+b+1), where a=f(x-1) and b=f(x-2), to reach a cycle.
0, 0, 4, 3, 0, 6, 6, 1, 13, 3, 2, 8, 3, 3, 5, 3, 0, 23, 3, 4, 11, 3, 0, 9, 11, 5, 9, 3, 10, 13, 13, 2, 5, 3, 9, 4, 7, 6, 23, 3, 34, 23, 8, 2, 12, 3, 22, 9, 8, 7, 16, 3, 1, 19, 60, 12, 27, 3, 7, 15, 22, 4, 25, 3, 30, 12, 10, 11, 22, 3, 6, 12, 3, 8, 19, 3, 10
Offset: 0
Keywords
Examples
For a(8), the sequence f is 8, 8, 13, 16, 28, 43, 52, 28, 79, 52, 16, 4, 1, and then 4, 4, 7 repeated, thus a(8) is 13.
Links
- Alex Costea, Table of n, a(n) for n = 0..10000
Programs
-
Mathematica
cyclePos[s_] := Module[{sp = SequencePosition[s[[1 ;; -3]], s[[-2 ;; -1]]]}, If[Length[sp] == 0, 0, sp[[1, 1]]]]; a[n_] := Module[{f, g}, g[a_, b_] := Mod[a*b, a + b + 1]; f[0] = f[1] = n; f[k_] := f[k] = g[f[k - 1], f[k - 2]]; s = {}; m = 0; While[Length[s] < 4 || cyclePos[s] == 0, AppendTo[s, f[m]]; m++]; cyclePos[s] - 1]; Array[a, 100, 0] (* Amiram Eldar, Jul 06 2019 *)
Comments