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.

A154770 a(n+1) = A154771(a(n)) = sum of all distinct "valid substrings" of a(n); a(1)=10 (least nontrivial choice).

Original entry on oeis.org

10, 11, 12, 15, 21, 24, 30, 33, 36, 45, 54, 63, 72, 81, 90, 99, 108, 127, 176, 283, 407, 458, 578, 733, 849, 1003, 1117, 1381, 2044, 2318, 2953, 4397, 5435, 6557, 7964, 9989, 12279, 16572, 26426, 36970, 49970, 67738, 84716, 100181, 111599, 139413, 209606
Offset: 1

Views

Author

Eric Angelini and M. F. Hasler, Jan 16 2009

Keywords

Comments

"Valid substrings" means all numbers that appear as substring of n (written in decimal system). Starting values < 10 would yield a constant sequence.

Examples

			a(1) = 10 has { 0, 1, 10 } as distinct substrings,
a(2) = 0+1+10 = 11 has { 1, 11 } as distinct substrings,
a(3) = 1+11 = 12 has { 1, 2, 12 } as distinct substrings,
a(4) = 1+2+12 = 15 has { 1, 5, 15 } as distinct substrings.
		

Crossrefs

Programs

  • PARI
    A154770( n=2, a=10 ) = { local(d); while( n--, a=vecsort(concat(vector(d=#Str(a),i,vector(d,j,a%10^j)+(d--&!a\=10))),NULL,8);a*=vector(#a,i,1)~); a }
    print1(a=10);for(i=1,50,print1("," a=A154770(,a)))

Extensions

The word "distinct" added to definition Jan 19 2009 at the suggestion of Hugo van der Sanden.

A120004 Number of distinct numbers as substrings of n in decimal representation.

Original entry on oeis.org

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

Views

Author

Reinhard Zumkeller, Jun 15 2006

Keywords

Comments

a(n) = A079790(n) for n <= 100;
a(A120005(n)) = n and a(m) < n for m < A120005(n).
a(n) = length of n-th row in A218978; see also A154771. - Reinhard Zumkeller, Nov 10 2012

Examples

			n=101: {'1','0','10','01','101'} -> a(101) = #{0,1,10,101} = 4;
n=102: {'1','0','2','10','02','102'} -> a(102) = #{0,1,2,10,102} = 5.
		

Crossrefs

Cf. A119999.

Programs

  • Haskell
    import Data.List (isInfixOf)
    a120004 n = sum $ map (fromEnum . (`isInfixOf` show n) . show) [0..n]
    -- Reinhard Zumkeller, Jul 16 2012, Aug 14 2011
    
  • Mathematica
    a[n_] := Length@ DeleteDuplicates[FromDigits /@ Rest@ Subsequences[ IntegerDigits[n]]]; Array[a, 100, 0] (* Amiram Eldar, Oct 19 2021 *)
  • PARI
    a(n) = if (n==0, return (1)); my(d=digits(n), list=List()); for (k=1, #d, for (j=1, #d-k+1, my(dk=vector(j, i, d[k+i-1])); listput(list, fromdigits(dk)););); #Set(list); \\
    
  • Python
    def A120004(n):
        s = str(n)
        m = len(s)
        return len(set(int(s[i:j]) for i in range(m) for j in range(i+1,m+1))) # Chai Wah Wu, Oct 19 2021

Extensions

Offset changed and a(0)=1 inserted, in consequence of Zak Seidov's correction in A120005. - Reinhard Zumkeller, May 30 2010

A218978 Table read by rows: n-th row lists all distinct substrings of decimal representation of n.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 10, 1, 11, 1, 2, 12, 1, 3, 13, 1, 4, 14, 1, 5, 15, 1, 6, 16, 1, 7, 17, 1, 8, 18, 1, 9, 19, 0, 2, 20, 1, 2, 21, 2, 22, 2, 3, 23, 2, 4, 24, 2, 5, 25, 2, 6, 26, 2, 7, 27, 2, 8, 28, 2, 9, 29, 0, 3, 30, 1, 3, 31, 2, 3, 32, 3
Offset: 0

Views

Author

Reinhard Zumkeller, May 02 2015, Nov 10 2012

Keywords

Comments

A120004(n) = length of n-th row;
A154771(n) = sum of n-th row.

Examples

			Rows 100 .. 112:
.  100:  {0, 1, 10, 100},
.  101:  {0, 1, 10, 101},
.  102:  {0, 1, 2, 10, 102},
.  103:  {0, 1, 3, 10, 103},
.  104:  {0, 1, 4, 10, 104},
.  105:  {0, 1, 5, 10, 105},
.  106:  {0, 1, 6, 10, 106},
.  107:  {0, 1, 7, 10, 107},
.  108:  {0, 1, 8, 10, 108},
.  109:  {0, 1, 9, 10, 109},
.  110:  {0, 1, 10 ,11, 110},
.  111:  {1, 11, 111},
.  112:  {1, 2, 11, 12, 112}.
		

Crossrefs

Cf. A031298, A219031 (squares in row), A262188 (palindromes in row).

Programs

  • Haskell
    import Data.List (inits, tails, sort, nub, genericIndex)
    a218978 n k = a218978_row n !! k
    a218978_row n = genericIndex a218978_tabf n
    a218978_tabf = map (sort . nub . map (foldr (\d v -> 10 * v + d) 0) .
                       concatMap (tail . inits) . tails) a031298_tabf
    -- Reinhard Zumkeller, corrected: Sep 15 2015, May 02 2015, Nov 10 2012

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