login
A386607
Smallest exponent b >= 2 such that the absolute value of the alternating digit sum of n^b = n or 0 if no such b exists.
3
2, 2, 6, 11, 21, 6, 16, 11, 26, 11, 0, 9, 3, 16, 51, 6, 11, 16, 81, 11, 36, 15, 13, 14, 26, 106, 26, 41, 101, 176, 96, 61, 16, 39, 36, 61, 36, 101, 46, 91, 226, 71, 91, 44, 53, 26, 61, 121, 76, 176, 206, 166, 251, 166, 39, 52, 47, 146, 236, 146, 261, 331, 166, 91, 86, 67, 42, 160, 271, 186, 841
OFFSET
0,1
COMMENTS
The sequence seems to exist for all n except positive powers of 10.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 0..2999 (terms 0..544 from Pieter Post)
FORMULA
a(n) = min{b >= 2 | abs(A225693(n^b)) = n} or 0 if the min does not exist.
a(10^k) = 0 for k > 0.
EXAMPLE
a(2) = 6 since 2^6 = 64 => |6-4| = 2.
a(3) = 11 since 3^11 = 177147 => |1-7+7-1+4-7| = 3.
a(12) = 3 since 12^3 = 1728 => |1-7+2-8| = 12.
MATHEMATICA
a[n_]:=Module[{b=2}, If[n>1&&IntegerQ[Log10[n]], b=0, While[s={1}; Do[AppendTo[s, (-1)^(k)], {k, 1, IntegerLength[n^b]-1}]; Abs[Total[IntegerDigits[n^b]*s]]!=n, b++]]; b]; Array[a, 71, 0] (* James C. McMahon, Nov 03 2025 *)
PROG
(Python)
from gmpy2 import digits
from itertools import count
def a(n):
if str(n).strip('0') == '1': return 2*int(n == 1)
return next(b for b in count(2) if n==abs(sum(-d if i&1 else d for i, d in enumerate(map(int, digits(n**b))))))
print([a(n) for n in range(101)]) # Michael S. Branicky, Oct 25 2025
(PARI) ispt(n) = if (n>1, 10^valuation(n, 10) == n);
as(n) = my(d=digits(n)); abs(sum(i=1, #d, d[i]*(-1)^i));
a(n) = if (ispt(n), 0, my(b=2); while (as(n^b) != n, b++); b); \\ Michel Marcus, Oct 24 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Pieter Post, Oct 24 2025
STATUS
approved