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.

A045888 Number of distinct odd numbers visible as proper subsequences of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 3, 1, 3
Offset: 1

Views

Author

Keywords

Examples

			The first nonzero entry is a(10) = 1 since we can see 1 as a proper subsequence of 10.
a(105) = 3 since we can see 1, 5, 15 (but not 105).
a(132) = 3 because we can see 1, 3, 13 (subsequences 12, 32 and 132 do not count as they are even and 132 also does not count as it does not come from a proper subsequence of digits of 132).
		

Crossrefs

Programs

  • Mathematica
    a[n_] := Count[Union[Most[Rest[Subsets[IntegerDigits[n]]]]], ?(First[#] > 0 && OddQ[Last[#]] &)]; Array[a, 100] (* _Amiram Eldar, Apr 12 2025 *)
  • PARI
    a(n) = {
        my(d = digits(n), odds = List());
        for(i = 1, #d,
            if(bitand(d[i], 1),
                forsubset(i-1, s,
                    c = fromdigits(vector(#s, j, d[s[j]])) * 10+d[i];
                    listput(odds, c))));
        #Set(odds)-bitand(n,1)
    } \\ David A. Corneth, Apr 13 2025
  • Python
    from itertools import combinations
    def a(n):
      s, eset = str(n), set()
      for i in range(len(s)):
        for j in range(i+1, len(s)+1):
          if s[j-1] in "13579":
            if len(s[i:j]) <= 2 and j-i < len(s):
              eset.add(int(s[i:j]))
            else:
              middle = s[i+1:j-1]
              for k in range(len(middle)+1):
                for c in combinations(middle, k):
                  t = s[i] + "".join(c) + s[j-1]
                  if len(t) < len(s):
                    eset.add(int(t))
      return len(eset)
    print([a(n) for n in range(1, 105)]) # Michael S. Branicky, Mar 24 2021
    

Extensions

More terms from Larry Reeves (larryr(AT)acm.org), Sep 28 2000
Revised by Sean A. Irvine, Mar 23 2021

A045887 Number of distinct even numbers visible as proper subsequences of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 2, 4, 2, 4
Offset: 0

Views

Author

Keywords

Examples

			a(10)=1 because we can form 0.
a(24)=2 because we can form 2, 4.
a(102)=4 because we can form 0, 2, 10, 12.
a(124)=5 because we can form the following even numbers: 2, 4, 12, 14, 24.
		

Crossrefs

Programs

  • Python
    from itertools import combinations
    def a(n):
      s, eset = str(n), set()
      for i in range(len(s)):
        for j in range(i+1, len(s)+1):
          if s[j-1] in "02468":
            if len(s[i:j]) <= 2 and j-i < len(s):
              eset.add(int(s[i:j]))
            else:
              middle = s[i+1:j-1]
              for k in range(len(middle)+1):
                for c in combinations(middle, k):
                  t = s[i] + "".join(c) + s[j-1]
                  if len(t) < len(s):
                    eset.add(int(t))
      return len(eset)
    print([a(n) for n in range(105)]) # Michael S. Branicky, Mar 24 2021

Extensions

More terms from Fabian Rothelius, Feb 08 2001
a(102) and a(104) corrected by Reinhard Zumkeller, Jul 19 2011
a(102) and a(104) reverted to original values by Sean A. Irvine, Mar 23 2021

A342846 Number of distinct odd numbers visible as proper substrings of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 2, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2
Offset: 1

Views

Author

Sean A. Irvine, Mar 24 2021

Keywords

Comments

Here substrings are contiguous.
a(A164766(n)) = n and a(m) <> n for m < A164766(n); a(A014263(n)) = 0. - Reinhard Zumkeller, Aug 25 2009

Examples

			a(10)=1 since we can see 1 as a proper substring of 10.
a(105)=2 since we can see 1, 5.
a(132)=3 because we can see 1, 3, 13.
		

Crossrefs

Programs

  • Haskell
    import Data.List (isInfixOf)
    a045888 n = length $ filter (`isInfixOf` (show n)) $ map show [1, 3..n-1]
    -- Reinhard Zumkeller, Jul 19 2011
    
  • Python
    def a(n):
      s, eset = str(n), set()
      for i in range(len(s)):
        for j in range(i+1, len(s)+1):
          if s[j-1] in "13579" and j-i < len(s): # odd and proper substring
            eset.add(int(s[i:j]))
      return len(eset)
    print([a(n) for n in range(1, 105)]) # Michael S. Branicky, Mar 24 2021
Showing 1-3 of 3 results.