OFFSET
1,2
COMMENTS
The digits 0, 1, 3, 6 and 9 will always be replaced by the same digits: 0 -> 0, 1 -> 1, 3 -> 9, 6 -> 9 and 9 -> 9.
LINKS
Sebastian Karlsson, Generalized and plotted in arbitrary bases
EXAMPLE
a(14) = 17, since 1^14 = 1 and 4^14 = 268435456. 2 + 6 + 8 + 4 + 3 + 5 + 4 + 5 + 6 = 43 and 4 + 3 = 7. Thus, the digital root of 268435456 is 7. This means that for 14, "1" gets replaced by "1" and "4" gets replaced by "7".
MATHEMATICA
digroot[n_] := If[n == 0, 0, Mod[n - 1, 9] + 1]; a[n_] := FromDigits[digroot /@ (IntegerDigits[n]^n)]; Array[a, 100] (* Amiram Eldar, Feb 24 2021 *)
PROG
(Python)
def D(d, n):
return 0 if d == 0 else (pow(d, n, 9)-1)%9 + 1
def a(n):
return int(''.join(str(D(int(d), n)) for d in str(n)))
(PARI) r(n) = if(n, (n-1)%9+1) \\ A010888
a(n) = fromdigits(apply(x->r(x^n), digits(n))); \\ Michel Marcus, Mar 21 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Sebastian Karlsson, Feb 24 2021
STATUS
approved