A307165 Numbers k such that the sequence f(0)=f(1)=k, f(x)=(a*b) mod (a+b+1), where a=f(x-1) and b=f(x-2) is a cycle.
0, 1, 4, 16, 22, 340
Offset: 1
Examples
Abmod(4,4) is [4,4,7,4,4,7,4,4,7,...].
Crossrefs
Cf. A307087.
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]; seq = {}; Do[If[a[j] == 0, AppendTo[seq, j]], {j, 0, 340}]; seq (* Amiram Eldar, Jul 06 2019 *)
Comments