# [seqfan] Orbit of k under repeated squaring mod n

Neil Sloane njasloane at gmail.com
Wed Dec 14 20:17:10 CET 2016

```This article

Haifeng Xu, <a href="http://arxiv.org/abs/1601.06509">The largest cycles
consist by the quadratic residues and Fermat primes</a>, arXiv:1601.06509
[math.NT], 2016,

although the English is hard to understand,  led me to create the triangle
A279185: T(n,k) (n>=1, 0 <=k<=n-1) is the length of the period of the
sequence obtained by starting with k and repeatedly squaring mod n.  For
example, if n=11 and k=2, repeatedly squaring mod 11 gives the sequence 2,
2^2 = 4, 4^2 = 16 == 5, 5^2 = 25 == 3, 9, 4, 5, 3, 9, 4, 5, 3, ..., which
has period length T(11,2) = 4. This ties together some old sequences and
some new ones. If I haven't made a mistake,

A279186 gives maximal entry in each row.

A037178 gives maximal entry in row p, p = n-th prime.

A279187 gives maximal entry in row c, c = n-th composite number.

A279188 gives maximal entry in row c, c = prime(n)^2.

A256608 gives LCM of entries in row n.

A256607 gives T(2,n).

and A279189 <https://oeis.org/A279189>, A279190 <https://oeis.org/A279190>,
A279191 <https://oeis.org/A279191>, A279192 <https://oeis.org/A279192> are
other new entries based on Xu's paper.  Many of these need checking, more
terms, programs, b-files, etc., and there are other sequences from Xu's
paper that could be added, if anyone would to help.  The sequences T(3,n),
T(4,n), ... are probably also worth adding (if they are new).
```