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.

A000030 Initial digit of n.

This page as a plain text file.
%I A000030 M0470 #91 Aug 28 2025 06:57:51
%S A000030 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,
%T A000030 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,
%U A000030 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
%N A000030 Initial digit of n.
%C A000030 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
%C A000030 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.
%D A000030 N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H A000030 David W. Wilson, <a href="/A000030/b000030.txt">Table of n, a(n) for n = 0..10000</a>
%H A000030 A. Cobham, <a href="http://dx.doi.org/10.1007/BF01706087">Uniform Tag Sequences</a>, Mathematical Systems Theory, 6 (1972), 164-192.
%F A000030 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
%F A000030 a(n) = k for k*10^j <= n < (k+1)*10^j for some j. - _M. F. Hasler_, Mar 23 2015
%e A000030 23 begins with a 2, so a(23) = 2.
%p A000030 A000030 := proc(n)
%p A000030     if n = 0 then
%p A000030         0;
%p A000030     else
%p A000030         convert(n,base,10) ;
%p A000030         %[-1] ;
%p A000030     end if;
%p A000030 end proc:
%p A000030 seq(A000030(n),n=0..200) ;# _N. J. A. Sloane_, Feb 10 2017
%t A000030 Join[{0},First[IntegerDigits[#]]&/@Range[90]] (* _Harvey P. Dale_, Mar 01 2011 *)
%t A000030 Table[Floor[n/10^(Floor[Log10[n]])], {n, 1, 50}] (* _G. C. Greubel_, May 16 2017 *)
%t A000030 Table[NumberDigit[n,IntegerLength[n]-1],{n,0,100}] (* _Harvey P. Dale_, Aug 29 2021 *)
%o A000030 (PARI) a(n)=if(n<10,n,a(n\10)) \\ Mainly for illustration.
%o A000030 (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
%o A000030 (Haskell) a000030 = until (< 10) (`div` 10) -- _Reinhard Zumkeller_, Feb 20 2012, Feb 11 2011
%o A000030 (Magma) [Intseq(n)[#Intseq(n)]: n in [1..100]]; // _Vincenzo Librandi_, Nov 17 2018
%o A000030 (Python)
%o A000030 def a(n): return int(str(n)[0])
%o A000030 print([a(n) for n in range(85)]) # _Michael S. Branicky_, Jul 01 2022
%Y A000030 Cf. A010879 (final digit of n).
%Y A000030 Cf. A061681, A130571, A109453, A134010, A052038.
%Y A000030 Cf. A002993, A089951, A002994, A143464, A098174, A098175, A072543, A072544, A073600, A073601, A037904. - _Reinhard Zumkeller_, Aug 17 2008
%K A000030 nonn,base,easy,nice,look,changed
%O A000030 0,3
%A A000030 _N. J. A. Sloane_, _Simon Plouffe_