OFFSET
1,5
COMMENTS
Is a(49) = 0? If a(49) != 0, it is > 100000 (10^5) (see A345115).
EXAMPLE
For n = 39: The trajectory of 39 under the given map starts 39, 132, 453, 987, 1866, 10527, 15798, 73779, 111576, 227337, 500709, 507804, 585849, 1444344, 5887785, 14765640, 62422041, 86642457, 153067035, 683737386, reaching the palindrome 683737386 after 19 iterations, so a(39) = 19.
PROG
(PARI) eva(n) = subst(Pol(n), x, 10)
rot(vec) = if(#vec < 2, return(vec)); my(s=concat(Str(2), ".."), v=[]); s=concat(s, Str(#vec)); v=vecextract(vec, s); v=concat(v, vec[1]); v
a(n) = my(x=n, i=0); while(1, x=x+eva(rot(digits(x))); i++; if(digits(x)==Vecrev(digits(x)), break)); i
(Python)
def pal(s): return s == s[::-1]
def rotl(s): return s[1:] + s[0]
def A345111(n): return n + int(rotl(str(n)))
def a(n):
i, iter, seen = 0, n, set()
while not (iter > n and pal(str(iter))) and iter not in seen:
seen.add(iter)
i, iter = i+1, A345111(iter)
return i if iter > n and pal(str(iter)) else 0
print([a(n) for n in range(1, 49)]) # Michael S. Branicky, Jun 09 2021
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Felix Fröhlich, Jun 09 2021
STATUS
approved