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

A073851 Cumulative sum of initial digits of (n base 5).

Original entry on oeis.org

0, 1, 3, 6, 10, 11, 12, 13, 14, 15, 17, 19, 21, 23, 25, 28, 31, 34, 37, 40, 44, 48, 52, 56, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121
Offset: 0

Views

Author

Jonathan Vos Post, Aug 28 2005

Keywords

Examples

			    n in   init  cumulative
n  base 5   dgt     sum
-  ------  ----  ----------
0     0      0       0
1     1      1       1
2     2      2       3
3     3      3       6
4     4      4      10
5    10      1      11
		

Crossrefs

Cf. A000030, A007091, A109453, A339255 (first differences).

Programs

  • PARI
    a(n) = if (n, sum(k=1, n, digits(k, 5)[1]), 0); \\ Michel Marcus, Dec 13 2017

Formula

a(n) = Sum_{i=0..n} A000030(A007091(n)).
a(n) = Sum_{i=0..n} first-digit(i base 4) where (i base 5) = A007091(i);
A007091(0)=0, A007091(i) = 10*A007091(i/5) if i == 0 (mod 5), A007091(i) = A007091(i-1) + 1 otherwise.
a(n) = Sum_{i=1..n} floor(n / 5^(floor(log_5(n)))).
a(n+1) = a(n) + first-digit-of((n+1) (base 5)).

A109804 Cumulative sum of initial digits of (n base 6).

Original entry on oeis.org

0, 1, 3, 6, 10, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 36, 39, 42, 45, 48, 51, 55, 59, 63, 67, 71, 75, 80, 85, 90, 95, 100, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131
Offset: 0

Views

Author

Jonathan Vos Post, Aug 30 2005

Keywords

Examples

			  n  Base 6  Initial  Cumulative Sum
  0     0       0           0
  1     1       1           1
  2     2       2           3
  3     3       3           6
  4     4       4          10
  5     5       5          15
		

References

  • A. Cobham, Uniform Tag Sequences, Mathematical Systems Theory, 6 (1972), 164-192.

Crossrefs

Cf. A000030, A007092, A109453, A339256 (first differences).

Programs

  • Mathematica
    Accumulate[Table[First[IntegerDigits[n,6]],{n,0,70}]] (* Harvey P. Dale, Oct 07 2012 *)

Formula

n (base 6) = A007092(n) A007092(0)=0, A007092(n)=10* A007092(n/6) if n==0 (mod 6), A007092(n)= A007092(n-1)+1 otherwise. - Benoit Cloitre, Dec 22 2002
a(n) below is Sum_{i=0..n} first-digit{(i base 6)}.
a(n) = Sum_{i=1..n} floor(n / 6^floor(log_6(n))) where log_6(n) is the logarithm to base 6.
a(n+1) = a(n) + first-digit-of((n+1) (base 6)).

A073849 Cumulative sum of initial digits of (n base 3).

Original entry on oeis.org

0, 1, 3, 4, 5, 6, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92
Offset: 0

Views

Author

Jonathan Vos Post, Aug 28 2005

Keywords

Examples

			    n in   init  cumulative
n  base 3   dgt     sum
-  ------  ----  ----------
0     0      0       0
1     1      1       1
2     2      2       3
3    10      1       4
4    11      1       5
5    12      1       6
		

Crossrefs

Programs

  • Mathematica
    Accumulate[Table[First[IntegerDigits[n,3]],{n,0,80}]] (* Harvey P. Dale, Mar 24 2015 *)
  • PARI
    lista(nn) = {s = 0; print1(s, ", "); for (n=1, nn, s += digits(n,3)[1]; print1(s, ", "););} \\ Michel Marcus, Mar 24 2015

Formula

a(n) = Sum_{i=0..n} A000030(A007089(n)).

Extensions

Corrected by Harvey P. Dale, Mar 24 2015

A073850 Cumulative sum of initial digits of (n base 4).

Original entry on oeis.org

0, 1, 3, 6, 7, 8, 9, 10, 12, 14, 16, 18, 21, 24, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 127, 128, 129, 130
Offset: 0

Views

Author

Jonathan Vos Post, Aug 28 2005

Keywords

Examples

			    n in   init  cumulative
n  base 4   dgt     sum
-  ------  ----  ----------
0     0      0       0
1     1      1       1
2     2      2       3
3     3      3       6
4    10      1       7
5    11      1       8
		

Crossrefs

Programs

  • Magma
    [0] cat [&+[Reverse(Intseq(k,4))[1]:k in [1..n]]:n in [1..70]]; // Marius A. Burtea, Dec 19 2019

Formula

a(n) = Sum_{i=0..n} A000030(A007090(n)).
a(n) = Sum_{i=0..n} first-digit(i base 4) where (i base 4) = A007090(i).
Showing 1-5 of 5 results.