cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A307551 Number of iterations of the map of quadratic residues x -> x^2 (mod prime(n)) with the initial term x = n^2 (mod prime(n)) needed to reach the end of the cycle.

This page as a plain text file.
%I A307551 #11 Jul 08 2019 06:29:45
%S A307551 0,0,1,1,3,2,3,1,9,3,3,5,5,5,10,11,27,4,9,2,3,11,19,11,4,20,7,51,17,2,
%T A307551 5,11,9,10,35,19,11,5,81,13,10,3,35,6,21,29,11,35,27,18,27,7,5,99,7,
%U A307551 129,65,35,10,2,22,9,23,19,13,38,19,8,171,27,13,177,59
%N A307551 Number of iterations of the map of quadratic residues x -> x^2 (mod prime(n)) with the initial term x = n^2 (mod prime(n)) needed to reach the end of the cycle.
%C A307551 Let L(n) be the number of elements in row n of A307550. Then a(n) = L(n) - 1.
%e A307551 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.
%p A307551 nn:=100:T:=array(1..3000):j:=0 :
%p A307551 for n from 1 to nn do:
%p A307551 p:=ithprime(n):lst0:={}:lst1:={}:ii:=0:r:=n:
%p A307551 for k from 1 to 10^6 while(ii=0) do:
%p A307551   r1:=irem(r^2,p):lst0:=lst0 union {r1}:j:=j+1:T[j]:=r1:
%p A307551       if lst0=lst1
%p A307551        then
%p A307551         ii:=1: printf(`%d, `,nops(lst0)-1):
%p A307551         else
%p A307551         r:=r1:lst1:=lst0:
%p A307551       fi:
%p A307551      od:
%p A307551    if lst0 intersect {r1} = {r1}
%p A307551     then
%p A307551     j:=j-1:else fi:
%p A307551 od:
%t A307551 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 *)
%Y A307551 Cf. A000040, A000224, A046071, A063987, A096008, A307550.
%K A307551 nonn
%O A307551 1,5
%A A307551 _Michel Lagneau_, Apr 14 2019