login
A378562
a(n) is the number of steps to reach 1 by reversing digits of n in the lowest base where reversal reduces the number.
1
0, 1, 1, 1, 1, 2, 2, 1, 1, 2, 3, 2, 4, 3, 3, 1, 5, 2, 4, 2, 2, 5, 5, 2, 5, 4, 1, 3, 6, 4, 4, 1, 5, 6, 4, 2, 5, 6, 5, 2, 6, 3, 5, 5, 3, 7, 7, 2, 5, 5, 6, 4, 6, 2, 7, 3, 6, 6, 8, 4, 8, 5, 2, 1, 9, 6, 7, 6, 6, 6, 8, 2, 5, 7, 6, 6, 9, 7, 7, 2, 7, 6, 7, 3, 5, 7, 8
OFFSET
1,6
COMMENTS
The procedure is guaranteed to reach 1 because n in base n is 10, and its reversal is 01 = 1.
LINKS
EXAMPLE
For n = 13, the a(13) = 4 steps in the trajectory to 1 are 13 -> 11 -> 7 -> 5 -> 1.
PROG
(Python) # see links for other versions
from functools import cache
from sympy.ntheory import digits
def fd(t, b): return sum(t[-1-i]*b**i for i in range(len(t)))
def f(n): return next(fd(r, b) for b in range(2, n+1) if (s:=digits(n, b)[1:]) > (r:=s[::-1]))
@cache
def a(n): return 0 if n == 1 else 1 + a(f(n))
print([a(n) for n in range(1, 88)]) # Michael S. Branicky, Dec 01 2024
CROSSREFS
Sequence in context: A305825 A366780 A324029 * A334046 A136605 A380367
KEYWORD
nonn,base,easy
AUTHOR
STATUS
approved