OFFSET
1,2
COMMENTS
The "rebase-and-read" operation is as follows:
1: Take n written in base 10, n = Sum_{i>=0} d_i * 10^i, and sum its digits together to obtain b = Sum_{i>=0} d_i.
2: If b = 1, then a(n) = n. Otherwise, "rebase": take n in base b so n = Sum_{i>=0} c_i * b^i and then "read" the digits c_i as base 10 to obtain a(n) = Sum_{i>=0} c_i * 10^i.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
For n = 8, its sum of digits is 8 and 8 = 1 * 8^1 + 0 * 8^0, so a(8) = 10.
For n = 100, its sum of the digits is 1, so by definition a(100) = 100.
For n = 1506, its sum of digits is 12 and 1506 = 10 * 12^2 + 5 * 12^1 + 6 * 12^0, so a(1506) = 10 * 10^2 + 5 * 10^1 + 6 * 10^0 = 1056.
MATHEMATICA
a[n_]:=If[IntegerQ[Log10[n]], n, FromDigits[IntegerDigits[n, DigitSum[n]]]]; Array[a, 61] (* James C. McMahon, Oct 16 2025 *)
PROG
(Python)
from sympy.ntheory import digits
def a(n): return n if (b:=sum(d:=list(map(int, str(n)))))<2 else sum(di*10**i for i, di in enumerate(digits(n, b)[:0:-1]))
print([a(n) for n in range(1, 62)]) # Michael S. Branicky, Oct 10 2025
(PARI) a(n) = my(s=sumdigits(n)); if (s==1, n, fromdigits(digits(n, s))); \\ Michel Marcus, Oct 13 2025
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Daniel Baldwin, Oct 10 2025
STATUS
approved
