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.

Showing 1-6 of 6 results.

A000030 Initial digit of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Keywords

Comments

When n - a(n)*10^[log_10 n] >= 10^[(log_10 n) - 1], where [] denotes floor, or when n < 100 and 10|n, n is the concatenation of a(n) and A217657(n). - Reinhard Zumkeller, Oct 10 2012, improved by M. F. Hasler, Nov 17 2018, and corrected by Glen Whitney, Jul 01 2022
Equivalent definition: The initial a(0) = 0 is followed by each digit in S = {1,...,9} once. Thereafter, repeat 10 times each digit in S. Then, repeat 100 times each digit in S, etc.

Examples

			23 begins with a 2, so a(23) = 2.
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a000030 = until (< 10) (`div` 10) -- Reinhard Zumkeller, Feb 20 2012, Feb 11 2011
    
  • Magma
    [Intseq(n)[#Intseq(n)]: n in [1..100]]; // Vincenzo Librandi, Nov 17 2018
    
  • Maple
    A000030 := proc(n)
        if n = 0 then
            0;
        else
            convert(n,base,10) ;
            %[-1] ;
        end if;
    end proc:
    seq(A000030(n),n=0..200) ;# N. J. A. Sloane, Feb 10 2017
  • Mathematica
    Join[{0},First[IntegerDigits[#]]&/@Range[90]] (* Harvey P. Dale, Mar 01 2011 *)
    Table[Floor[n/10^(Floor[Log10[n]])], {n, 1, 50}] (* G. C. Greubel, May 16 2017 *)
    Table[NumberDigit[n,IntegerLength[n]-1],{n,0,100}] (* Harvey P. Dale, Aug 29 2021 *)
  • PARI
    a(n)=if(n<10,n,a(n\10)) \\ Mainly for illustration.
    
  • PARI
    A000030(n)=n\10^logint(n+!n,10) \\ Twice as fast as a(n)=digits(n)[1]. Before digits() was added in PARI v.2.6.0 (2013), one could use, e.g., Vecsmall(Str(n))[1]-48. - M. F. Hasler, Nov 17 2018
    
  • Python
    def a(n): return int(str(n)[0])
    print([a(n) for n in range(85)]) # Michael S. Branicky, Jul 01 2022

Formula

a(n) = [n / 10^([log_10(n)])] where [] denotes floor and log_10(n) is the logarithm is base 10. - Dan Fux (dan.fux(AT)OpenGaia.com or danfux(AT)OpenGaia.com), Apr 07 2001
a(n) = k for k*10^j <= n < (k+1)*10^j for some j. - M. F. Hasler, Mar 23 2015

A371706 a(n) is the least k > 0 such that n^k contains the digit 1.

Original entry on oeis.org

1, 4, 4, 2, 3, 3, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 3, 3, 3, 3, 3, 3, 3, 2, 4, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 3, 2, 3, 3, 2, 3, 1, 3, 3, 2, 3, 2, 3, 3, 2, 3, 1, 4, 4, 3, 4, 4, 4, 3, 2, 4, 1, 2, 3, 5, 3, 4, 4, 4, 2, 3, 1, 3, 3, 4, 3, 4, 4, 3, 2, 2, 1, 4, 4, 6, 4, 2, 3, 3, 2
Offset: 1

Views

Author

Robert Israel, Apr 03 2024

Keywords

Comments

First n such that a(n) = k: 1, 4, 5, 2, 74, 94, 305, 2975 for k = 1 to 8.
a(n) <= 8 for n <= 240000000. Is a(n) ever greater than 8?
a(n) <= 8 for n <= 10^11. Moreover the only n <= 10^11 with a(n) = 8 are 2975 * 10^j. - Robert Israel, Apr 05 2024
a(n) <= 8 for n <= 10^13, and a(n) <= 17 for all n; see A275533. - Michael S. Branicky, Apr 08 2024

Examples

			a(3) = 4 because 3^1, 3^2 = 9 and 3^3 = 27 have no 1's, but 3^4 = 81 does have a 1.
		

Crossrefs

Programs

  • Maple
    g:= proc(n) local k;
       for k from 1 do if member(1,convert(n^k,base,10)) then return k fi od;
    end proc:
    map(g, [$1..100]);
  • Mathematica
    seq={};Do[k=1;While[!ContainsAny[IntegerDigits[n^k],{1}],k++];AppendTo[seq,k],{n,99}];seq (* James C. McMahon, Apr 05 2024 *)
  • Python
    from itertools import count
    def A371706(n):
        m = n
        for k in count(1):
            if '1' in str(m):
                return k
            m *= n # Chai Wah Wu, Apr 04 2024

Formula

a(n) <= A098174(n).

A098175 Smallest power of n with initial digit = 1 in decimal representation.

Original entry on oeis.org

1, 16, 19683, 16, 125, 1296, 16807, 16777216, 1853020188851841, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 160000, 194481, 10648, 12167, 13824, 15625, 17576, 19683, 17210368, 17249876309, 19683000000000
Offset: 1

Views

Author

Reinhard Zumkeller, Aug 30 2004

Keywords

Comments

A000030(a(n)) = 1; a(n) = n^A098174(n).

Programs

  • Mathematica
    f[n_] := Block[{k = 1}, While[IntegerDigits[n^k][[1]] != 1, k++ ]; n^k]; Table[ f[n], {n, 30}] (* Robert G. Wilson v, Sep 01 2004 *)

A309736 a(1) = 1, and for any n > 1, a(n) is the least k > 0 such that the binary representation of n^k starts with "10".

Original entry on oeis.org

1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 1, 2, 2, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5, 6, 10, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 1

Views

Author

Rémy Sigrist, Aug 14 2019

Keywords

Comments

The sequence is well defined; for any n > 0:
- if n is a power of 2, then a(n) = 1,
- if n is not a power of 2, then log_2(n) is irrational,
hence the function k -> frac(k * log_2(n)) is dense in the interval [0, 1]
according to Weyl's criterion,
so for some k > 0, k*log_2(n) = m + 1 + e where m is a positive integer
and 0 <= e < log_2(3) - 1 < 1,
- hence 2 * 2^m <= n^k < 3 * 2^m and a(n) <= k, QED.

Examples

			For n = 7:
- the first powers of 7, in decimal as well as in binary, are:
    k  7^k  bin(7^k)
    -  ---  ---------
    1    7        111
    2   49     110001
    3  343  101010111
- hence a(7) = 3.
		

Crossrefs

Programs

  • PARI
    a(n) = { my (nk=n); for (k=1, oo, if (binary(2*nk)[2]==0, return (k), nk *= n)) }

Formula

a(n) = 1 iff n belongs to A004754.
a(2*n) = a(n).
A090996(n^a(n)) = 1.

A363683 Square array A(n, k), n, k > 0, read by antidiagonals; A(n, k) is the least e > 0 such that n^e and k^e have the same initial digit, or -1 if no such e exists.

Original entry on oeis.org

1, 4, 4, 9, 1, 9, 2, 17, 17, 2, 3, 7, 1, 7, 3, 4, 5, 8, 8, 5, 4, 5, 4, 9, 1, 9, 4, 5, 8, 2, 3, 11, 11, 3, 2, 8, 16, 5, 11, 6, 1, 6, 11, 5, 16, 1, 17, 7, 4, 9, 9, 4, 7, 17, 1, 1, 4, 17, 10, 6, 1, 6, 10, 17, 4, 1, 1, 4, 9, 14, 5, 15, 15, 5, 14, 9, 4, 1
Offset: 1

Views

Author

Rémy Sigrist, Jun 15 2023

Keywords

Comments

Conjecture: all terms are positive.

Examples

			Array A(n, k) begins:
  n\k |  1   2   3   4   5   6   7   8   9  10  11  12
  ----+-----------------------------------------------
    1 |  1   4   9   2   3   4   5   8  16   1   1   1
    2 |  4   1  17   7   5   4   2   5  17   4   4   9
    3 |  9  17   1   8   9   3  11   7  17   9  16   5
    4 |  2   7   8   1  11   6   4  10  14   2   2   2
    5 |  3   5   9  11   1   9   6   5   4   3   3   3
    6 |  4   4   3   6   9   1  15   7  11   4   4  10
    7 |  5   2  11   4   6  15   1  17  18   5   5   4
    8 |  8   5   7  10   5   7  17   1  18   8  28   6
    9 | 16  17  17  14   4  11  18  18   1  16  23   8
   10 |  1   4   9   2   3   4   5   8  16   1   1   1
   11 |  1   4  16   2   3   4   5  28  23   1   1   1
   12 |  1   9   5   2   3  10   4   6   8   1   1   1
		

Crossrefs

Programs

  • PARI
    A(n,k) = { for (e = 1, oo, if (digits(n^e)[1]==digits(k^e)[1], return (e));); }

Formula

A(n, k) = A(k, n).
A(10*n, k) = A(n, k).
A(n, n) = 1.
A(n, 1) = A098174(n).

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
    
Showing 1-6 of 6 results.