cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A367821 a(n) = first exponent k such that n^k starts with 9 or -1 if n is a power of 10.

This page as a plain text file.
%I A367821 #33 Jan 05 2024 14:26:13
%S A367821 -1,53,2,78,10,176,13,21,1,-1,24,25,26,34,17,39,13,39,25,53,3,32,11,
%T A367821 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,
%U A367821 13,10,24,60,11,15,4,4,37,17,22,176,14,5,5,26,43,39,6,6,25,13,7
%N A367821 a(n) = first exponent k such that n^k starts with 9 or -1 if n is a power of 10.
%C A367821 First k such that log_10(9) <= fractional part of k*log_10(n) < 1.
%C A367821 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.
%e A367821 a(2) = 53 because smallest power of 2 that starts with 9 is 2^53 = 9007199254740992. See A018856.
%e A367821 a(3) = 2 because 3^2 = 9.
%o A367821 (Python)
%o A367821 def a(n: int) -> int:
%o A367821     s = str(n)
%o A367821     if n <= 1 or (s[0] == '1' and set(s[1:]) == {'0'}):
%o A367821         return -1
%o A367821     pwr, e = 1, 0
%o A367821     while str(pwr)[0] != '9':
%o A367821         pwr *= n
%o A367821         e += 1
%o A367821     return e
%o A367821 (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
%Y A367821 Cf. A018856, A098174, A367854 (record high indices).
%K A367821 sign,easy,base
%O A367821 1,2
%A A367821 _William Hu_, Dec 01 2023