login
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

%I #32 Dec 16 2024 14:58:56

%S 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,

%T 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,

%U 6,6,8,2,5,7,6,6,9,7,7,2,7,6,7,3,5,7,8

%N a(n) is the number of steps to reach 1 by reversing digits of n in the lowest base where reversal reduces the number.

%C The procedure is guaranteed to reach 1 because n in base n is 10, and its reversal is 01 = 1.

%H Michael S. Branicky, <a href="/A378562/b378562.txt">Table of n, a(n) for n = 1..10000</a>

%H Michael S. Branicky, <a href="/A378562/a378562.py.txt">Alternate Python programs for A378562</a>

%e For n = 13, the a(13) = 4 steps in the trajectory to 1 are 13 -> 11 -> 7 -> 5 -> 1.

%o (Python) # see links for other versions

%o from functools import cache

%o from sympy.ntheory import digits

%o def fd(t, b): return sum(t[-1-i]*b**i for i in range(len(t)))

%o def f(n): return next(fd(r, b) for b in range(2, n+1) if (s:=digits(n, b)[1:]) > (r:=s[::-1]))

%o @cache

%o def a(n): return 0 if n == 1 else 1 + a(f(n))

%o print([a(n) for n in range(1, 88)]) # Michael S. Branicky, Dec 01 2024

%Y Cf. A004086, A030101.

%K nonn,base,easy

%O 1,6

%A _Asier Rodriguez Escalante_, Nov 30 2024