OFFSET
1,2
COMMENTS
Equivalently, the number of limit cycles formed by iterating the map j -> j*k (mod n).
Cycles are distinct if their elements are reached in a distinct order. For example, the cycle (2 4 8 6) is the same as (4 8 6 2), but distinct from (6 8 4 2).
LINKS
Ali Sada, Ordered Cycles of the Last Digit Under Repeated Multiplication (Base 10), SeqFan, Jan 13 2026.
EXAMPLE
For n=10, the a(10) = 18 cycles which occur are
k=1: 10 cycles of fixed points {0}, {1}, ..., {9}.
k=2: 1 cycle {2,4,8,6} and otherwise fixed points already seen.
k=3: 2 cycles {1,3,9,7} and {6,8,4,2}.
k=4: 2 cycles {2,8} and {4,6}.
k=5: only fixed points; no new cycles.
k=6: no new cycles.
k=7: 1 new cycle {7,9,3,1}, and {4,8,6,2} already seen.
k=8: no new cycles, only {6,8,4,2} already seen.
k=9: 2 cycles {1,9}, {7,3}, and {8,2}, {4,6} already seen.
PROG
(PARI)
find(x, S) = for(i=1, #S, S[i]==x && return(i))
digit_cycles(base)={ my(S=[[k] | k<-[0..base-1]], orbit, t); for(k = 2, base-1, for(d=1, base-1, orbit=[t=d]; while(!setsearch(Set(orbit), t = t*k%base), orbit=concat(orbit, t)); t != orbit[1] && orbit = orbit[find(t, orbit) .. -1]; t = find(vecmin(orbit), orbit); t != 1 && orbit = concat(orbit[t .. -1], orbit[1 .. t-1]); S = setunion( S, [orbit] ))); S};
A390033(n)=#digit_cycles(base) \\ M. F. Hasler, Jan 17 2026
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Ali Sada, Jan 14 2026
STATUS
approved
