OFFSET
1,5
COMMENTS
Let L(n) be the number of elements in row n of A307550. Then a(n) = L(n) - 1.
EXAMPLE
a(5) = 3 because prime(5) = 11, and 5^2 (mod 11) = 3 -> 3^2 (mod 11) = 9 -> 9^2 (mod 11) = 4 -> 4^2 (mod 11) = 5 with 3 iterations, where 5 is the last term of the cycle.
MAPLE
nn:=100:T:=array(1..3000):j:=0 :
for n from 1 to nn do:
p:=ithprime(n):lst0:={}:lst1:={}:ii:=0:r:=n:
for k from 1 to 10^6 while(ii=0) do:
r1:=irem(r^2, p):lst0:=lst0 union {r1}:j:=j+1:T[j]:=r1:
if lst0=lst1
then
ii:=1: printf(`%d, `, nops(lst0)-1):
else
r:=r1:lst1:=lst0:
fi:
od:
if lst0 intersect {r1} = {r1}
then
j:=j-1:else fi:
od:
MATHEMATICA
a[n_] := Module[{p = Prime[n]}, f[x_] := Mod[x^2, p]; Length[NestWhileList[f, f[n], Unequal, All]] - 2]; Array[a, 100] (* Amiram Eldar, Jul 05 2019 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Michel Lagneau, Apr 14 2019
STATUS
approved