cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A345112 a(n) is the number of steps to reach a palindrome > n under repeated applications of the map x -> A345111(x) starting with n, or 0 if no palindrome is ever reached.

Original entry on oeis.org

1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 19, 1, 1, 1, 1, 1, 1, 3, 1, 19
Offset: 1

Views

Author

Felix Fröhlich, Jun 09 2021

Keywords

Comments

Is a(49) = 0? If a(49) != 0, it is > 100000 (10^5) (see A345115).

Examples

			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.
		

Crossrefs

Programs

  • 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