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-4 of 4 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

A052039 a(n) is the smallest k such that the first significant digits of 1/k coincide with n.

Original entry on oeis.org

1, 4, 3, 21, 2, 15, 13, 12, 11, 91, 9, 8, 72, 7, 63, 6, 56, 53, 51, 48, 46, 44, 42, 41, 4, 38, 36, 35, 34, 33, 32, 31, 3, 29, 28, 271, 27, 26, 251, 244, 24, 233, 23, 223, 22, 213, 21, 205, 201, 197, 193, 19, 186, 182, 18, 176, 173, 17, 167, 164, 162, 16, 157, 154, 152
Offset: 1

Views

Author

Patrick De Geest, Dec 15 1999

Keywords

Comments

This sequence differs from A326818 in how it treats reciprocals with terminating representation, i.e., the values 1/k for integers k whose prime factors are 2 and/or 5. For example, in A326818 we assume 1/5 = 0.2000... which leads to A326818(20) = 5, while here we consider 1/5 = 0.2 (without trailing zeros), which leads to a(20) = 48 instead. - Giovanni Resta, Oct 20 2019

Examples

			a(36) = 271 because 1/271 = 0.00{36}9003690036900... and 271 is the smallest number with this property.
		

Crossrefs

Programs

  • Mathematica
    dinv[x_, m_] := Block[{t = If[1 == x/ 2^IntegerExponent[x,2]/ 5^IntegerExponent[x,5], RealDigits[1/x], RealDigits[1/x, 10, m]][[1]]}, If[ Length[t] > m, Take[t, m], t]]; a[n_] := Block[{d = IntegerDigits[n], m, k = 1}, m = Length[d]; While[dinv[k, m] != d, k++]; k]; Array[a, 65] (* Giovanni Resta, Oct 20 2019 *)

A061861 First two significant digits of 1/n written in decimal.

Original entry on oeis.org

10, 50, 33, 25, 20, 16, 14, 12, 11, 10, 90, 83, 76, 71, 66, 62, 58, 55, 52, 50, 47, 45, 43, 41, 40, 38, 37, 35, 34, 33, 32, 31, 30, 29, 28, 27, 27, 26, 25, 25, 24, 23, 23, 22, 22, 21, 21, 20, 20, 20, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 16, 15, 15, 15, 15, 14, 14, 14
Offset: 1

Views

Author

Henry Bottomley, May 11 2001

Keywords

Comments

After 10^k terms the number of times m will have appeared will be about 10^(k+2)/(9*m*(m+1)); e.g., 10 will appear just over 10.1% of the time.

Examples

			a(32)=31 since 1/32 = 0.0312500000...
		

Crossrefs

Programs

  • Mathematica
    Table[FromDigits[RealDigits[1/n,10,2][[1]]],{n,70}] (* Harvey P. Dale, Jan 19 2018 *)

Formula

a(n) = floor(10^floor(2+log_10(n-1))/n).

A353179 a(n) is the first nonzero digit in the decimal expansion of 1/prime(n).

Original entry on oeis.org

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

Views

Author

Firdous Ahmad Mala, Apr 29 2022

Keywords

Crossrefs

Programs

  • Maple
    a:= n-> (p-> floor(10^length(p)/p))(ithprime(n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Apr 30 2022
  • Mathematica
    Table[RealDigits[1/Prime[n],10,1][[1]],{n,100}]//Flatten (* Harvey P. Dale, Aug 25 2024 *)
  • PARI
    a(n) = my(p=prime(n)); floor(10^(1+logint(p-1, 10))/p) \\ Felix Fröhlich, Apr 29 2022

Formula

a(n) = A052038(prime(n)).

Extensions

More terms from Felix Fröhlich, Apr 29 2022
Showing 1-4 of 4 results.