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-3 of 3 results.

A154771 Sum of all numbers that appear as substring of n, written in decimal system.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 17, 19, 21, 23, 25, 27, 29, 22, 24, 24, 28, 30, 32, 34, 36, 38, 40, 33, 35, 37, 36, 41, 43, 45, 47, 49, 51, 44, 46, 48, 50, 48, 54, 56, 58, 60, 62, 55, 57, 59, 61, 63, 60, 67, 69, 71, 73, 66, 68, 70, 72, 74, 76, 72, 80, 82, 84, 77, 79, 81
Offset: 0

Views

Author

M. F. Hasler, Jan 16 2009

Keywords

Comments

a(n) is the sum of n-th row in A218978; see also A120004. - Reinhard Zumkeller, Nov 10 2012

Examples

			Since n=0,...,9 has a single digit, only n itself appears as substring in k, thus a(n)=n.
10 has { 0, 1, 10 } as substrings, thus a(10) = 0+1+10 = 11.
11 has { 1, 11 } as substrings, thus a(11) = 1+11 = 12.
12 has { 1, 2, 12 } as substrings, thus a(12) = 1+2+12 = 15.
		

Crossrefs

Programs

  • Haskell
    a154771 = sum . a218978_row :: Integer -> Integer
    -- Reinhard Zumkeller, Nov 10 2012
    
  • PARI
    A154771(n) = { local(d=#Str(n)); n=vecsort(concat(vector(d,i,vector(d,j,n%10^j)+(d--&!n\=10))),,8);n*vector(#n,i,1)~ }
    
  • Python
    def a(n):
        s = str(n); L = len(s)
        return sum(set(int(s[i:j]) for i in range(L) for j in range(i+1, L+1)))
    print([a(n) for n in range(73)]) # Michael S. Branicky, Nov 08 2022

Formula

a(n) = n+A154781(n).
a(10^n) = A002275(n+1).

A225580 The sum of all substrings of n (including n).

Original entry on oeis.org

1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 66, 68, 70, 72, 74, 76, 78, 80
Offset: 1

Views

Author

Keywords

Comments

This sequence differs from A071980 beginning with n = 1010, and differs formulaically beginning with n = 1000 (the first four digit number). Where A071980 is calculated as a + ab + abc + abcd + bcd + cd + d for four digit numbers abcd, this sequence also includes the term bc in the sum.
Limits: n <= a(n) < 1.73*n. Proof: a(n)/n will be maximized when substrings are as large as possible while n is as small as possible, or for numbers of the form 199999999... The sum of substrings of this number is < 222222... + < 1234567... or < 3456790123.../2000000000... or < 1.728396.
The number 111 is the smallest term that occurs twice in the sequence, when n = {96, 100}. The number 2254 is the smallest term that occurs three times in the sequence, when n = {1476, 1510, 2008}.

Examples

			For n=1980, a(n) = 1 + 9 + 8 + 0 + 19 + 98 + 80 + 198 + 980 + 1980 = 3373. Note that A071980(1980) = 3258, because it does not include 9, 8, 98 in the sum.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local i,d,L;
      L:= convert(n,base,10);
      d:= nops(L);
      add(L[i]*(d-i+1)*(10^i - 1)/9, i=1..d);
    end proc:
    map(f, [$1..100]); # Robert Israel, May 15 2025
  • Mathematica
    Table[s = IntegerDigits[n]; Total[Flatten[Table[FromDigits /@ Partition[s, i, 1], {i, Length[s]}]]], {n, 100}] (* T. D. Noe, May 13 2013 *)
  • Python
    def a(n):
        s = str(n)
        return sum(int(s[i:j]) for j in range(1, len(s)+1) for i in range(j))
    # David Radcliffe, May 15 2025
  • R
    sapply(1:100,function(n) {tot=0; s=as.character(n); len=nchar(s); for(i in 1:len) for(j in i:len) tot=tot+as.numeric(substr(s,i,j)); tot})
    

Formula

a(n) = A138953(n) + n. (Note the offset in A138953 is zero. - Zak Seidov, May 16 2013)
a(n) = 11*a(floor(n/10)) - 10*a(floor(n/100)) + (n mod 10) * A055642(n). - David Radcliffe, May 15 2025

Extensions

Example corrected by Zak Seidov, May 16 2013

A154781 Sum of all numbers < n that appear as substring of n, written in decimal system.

Original entry on oeis.org

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

Views

Author

M. F. Hasler, Jan 16 2009

Keywords

Comments

The condition "< n" narrows the meaning of "substring" to the strict sense, i.e., excludes n itself.

Examples

			Since n=0,...,9 has a single digit, only n itself appears as substring in n, thus a(n)=0.
10 has { 0, 1, 10 } as substrings, thus a(10) = 0+1 = 1.
11 has { 1, 11 } as substrings, thus a(11) = 1.
12 has { 1, 2, 12 } as substrings, thus a(12) = 1+2 = 3.
		

Crossrefs

Programs

  • Mathematica
    san[n_]:=Total[Union[FromDigits/@Flatten[Table[Partition[IntegerDigits[n],i,1],{i,IntegerLength[n]-1}],1]]]; Array[san,90,0] (* Harvey P. Dale, May 27 2017 *)
  • PARI
    A154781(n) = { local(d=#Str(n)); n=vecsort(concat(vector(d,i,vector(d,j,n%10^j)+(d--&!n\=10))),,12);n*vector(#n,i,i>1)~ }
    
  • Python
    def a(n):
        s = str(n)
        return sum(set(int(s[i:j]) for i in range(len(s)) for j in range(i+1, len(s)+1))) - n
    print([a(n) for n in range(90)]) # Michael S. Branicky, Nov 08 2022

Formula

a(n) = A154771(n)-n. a(10^n) = A002275(n). a(n)>0 <=> n>9.
Showing 1-3 of 3 results.