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

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
Showing 1-1 of 1 results.