login
A367821
a(n) = first exponent k such that n^k starts with 9 or -1 if n is a power of 10.
1
-1, 53, 2, 78, 10, 176, 13, 21, 1, -1, 24, 25, 26, 34, 17, 39, 13, 39, 25, 53, 3, 32, 11, 21, 5, 12, 37, 29, 41, 2, 2, 89, 25, 15, 11, 88, 7, 12, 5, 78, 13, 8, 11, 45, 3, 3, 55, 22, 13, 10, 24, 60, 11, 15, 4, 4, 37, 17, 22, 176, 14, 5, 5, 26, 43, 39, 6, 6, 25, 13, 7
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
Cf. A018856, A098174, A367854 (record high indices).
Sequence in context: A116107 A114787 A198776 * A051320 A232126 A078681
KEYWORD
sign,easy,base
AUTHOR
William Hu, Dec 01 2023
STATUS
approved