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.

Original entry on oeis.org

-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

Views

Author

William Hu, Dec 01 2023

Keywords

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.

Examples

			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.
		

Crossrefs

Cf. A018856, A098174, A367854 (record high indices).

Programs

  • 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
  • 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