OFFSET
1,2
COMMENTS
First k such that log_10(9) <= fractional part of k*log_10(n) < 1.
For a non-power of 10, the leading digits of the powers of n follow Benford's law, therefore making 9 the least common leading digit of powers of n.
EXAMPLE
a(2) = 53 because smallest power of 2 that starts with 9 is 2^53 = 9007199254740992. See A018856.
a(3) = 2 because 3^2 = 9.
PROG
(Python)
def a(n: int) -> int:
s = str(n)
if n <= 1 or (s[0] == '1' and set(s[1:]) == {'0'}):
return -1
pwr, e = 1, 0
while str(pwr)[0] != '9':
pwr *= n
e += 1
return e
(PARI) a(n) = my(t); if ((n==1) || (n==10) || (ispower(n, , &t) && (t==10)), -1, my(k=1); while (digits(n^k)[1] != 9, k++); k); \\ Michel Marcus, Dec 03 2023
CROSSREFS
KEYWORD
sign,easy,base
AUTHOR
William Hu, Dec 01 2023
STATUS
approved