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.

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

This page as a plain text file.
%I A045887 #26 Mar 24 2021 22:15:20
%S A045887 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,
%T A045887 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,
%U A045887 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
%N A045887 Number of distinct even numbers visible as proper subsequences of n.
%H A045887 Sean A. Irvine, <a href="/A045887/b045887.txt">Table of n, a(n) for n = 0..10000</a>
%H A045887 Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a045/A045887.java">Java program</a> (github)
%e A045887 a(10)=1 because we can form 0.
%e A045887 a(24)=2 because we can form 2, 4.
%e A045887 a(102)=4 because we can form 0, 2, 10, 12.
%e A045887 a(124)=5 because we can form the following even numbers: 2, 4, 12, 14, 24.
%o A045887 (Python)
%o A045887 from itertools import combinations
%o A045887 def a(n):
%o A045887   s, eset = str(n), set()
%o A045887   for i in range(len(s)):
%o A045887     for j in range(i+1, len(s)+1):
%o A045887       if s[j-1] in "02468":
%o A045887         if len(s[i:j]) <= 2 and j-i < len(s):
%o A045887           eset.add(int(s[i:j]))
%o A045887         else:
%o A045887           middle = s[i+1:j-1]
%o A045887           for k in range(len(middle)+1):
%o A045887             for c in combinations(middle, k):
%o A045887               t = s[i] + "".join(c) + s[j-1]
%o A045887               if len(t) < len(s):
%o A045887                 eset.add(int(t))
%o A045887   return len(eset)
%o A045887 print([a(n) for n in range(105)]) # _Michael S. Branicky_, Mar 24 2021
%Y A045887 Cf. A045888, A342845, A342846.
%K A045887 base,easy,nonn
%O A045887 0,21
%A A045887 _Felice Russo_
%E A045887 More terms from _Fabian Rothelius_, Feb 08 2001
%E A045887 a(102) and a(104) corrected by _Reinhard Zumkeller_, Jul 19 2011
%E A045887 a(102) and a(104) reverted to original values by _Sean A. Irvine_, Mar 23 2021