login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A045887
Number of distinct even numbers visible as proper subsequences of n.
4
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,21
LINKS
Sean A. Irvine, Java program (github)
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
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
STATUS
approved