OFFSET
1,2
FORMULA
For n >= 9, a(n) = a(n-1) + 2*n - 4 - ceiling(log_2 (n)) or a(n) = n^2 - 3*n - 17 - Sum_{i=9..n} ceiling(log_2 (i)).
EXAMPLE
a(1) = 1. It takes one step to repeat the last digit by iterating the map on an integer. For example, 2^5 = 32 and 9^5 = 59049. Thus, the distinct number of steps for n = 1 is {1} and a(1) = 1.
a(2) = 2. It takes 1 or 2 steps for an integer to repeat its last two digits. For example, 24 -> 7962624; 27 -> 14348907 -> 608266787713357709119683992618861307. Thus, a(2) = 2: {1, 2}.
a(3) = 3: {1..3}.
a(4) = 4: {1..4}.
a(5) = 6: {1..6}.
a(6) = 9: {1..9}.
a(7) = 14: {1..14}.
a(8) = 23: {1..23}.
a(9) = 33: {1..24, 32..40}.
a(10) = 45: {1..25, 32..41, 64..73}.
a(11) = 59: {1..26, 32..42, 64..74, 128..138}.
PROG
(Python)
from math import log, ceil
def A350588(n):
if n <= 8:
b, S = 10**n, set()
for i in range(b):
t, s, T = i, 0, set()
while t not in T: T.add(t); t = (t**5)%b; s += 1
S.add(s)
return(len(S))
else: return n*n - 3*n - 17 - sum(ceil(log(i, 2)) for i in range(9, n+1))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Ya-Ping Lu, Jan 07 2022
STATUS
approved