OFFSET
2,1
COMMENTS
The trajectory from every starting point will enter a cycle given a sufficient number of iterations of f_n.
To determine a(n), only starting points 0, 1, 2, ..., n^2 have to be checked for cycles. Larger starting points will always lead to a cycle reached from one (or more) of 0, 1, 2, ..., n^2.
From Iain Fox, Jul 09 2022: (Start)
Since f_n(x) <= (n-1)*(1 + floor(2*log_n(x))), only numbers less than the largest zero of (n-1)*(1 + floor(2*log_n(x))) - x need to be checked.
The value mentioned above is less than or equal to (2-2n)*W_{-1}(log(n)/((2-2n)*sqrt(n)))/log(n) where W_k(x) is the k-th branch of the Lambert W function. (End)
LINKS
Iain Fox, Table of n, a(n) for n = 2..10000
EXAMPLE
a(8) = 4 because there are 4 cycles for n = 8:
f_8(0) = 0 (since 0^2 = 0 = 0_8, with digit sum 0),
f_8(1) = 1 (1^2 = 1 = 1_8, with digit sum 1),
f_8(4) = 2 (4^2 = 20_8) and f_8(2) = 4 (2^2 = 4_8), and
f_8(7) = 7 (7^2 = 61_8, with digit sum 7).
PROG
(PARI) a(n) = my(d=1); while(d<=logint(((n-1)*d)^2, n)+1, d++); my(l=(n-1)*(d-1)+1, x=vector(l, i, l-i), y=[], z=[], j, c=0); for(i=1, #x, y=setunion(y, z); j=x[i]; z=[]; while(!setsearch(z, j), if(setsearch(y, j), next(2)); z=setunion(z, [j]); j=sumdigits(j^2, n)); c++); c \\ Iain Fox, Jul 09 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Wouter Zandsteeg, Jul 04 2022
STATUS
approved