login
Number of distinct even numbers visible as proper subsequences of n.
4

%I #26 Mar 24 2021 22:15:20

%S 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 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 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 Number of distinct even numbers visible as proper subsequences of n.

%H Sean A. Irvine, <a href="/A045887/b045887.txt">Table of n, a(n) for n = 0..10000</a>

%H Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a045/A045887.java">Java program</a> (github)

%e a(10)=1 because we can form 0.

%e a(24)=2 because we can form 2, 4.

%e a(102)=4 because we can form 0, 2, 10, 12.

%e a(124)=5 because we can form the following even numbers: 2, 4, 12, 14, 24.

%o (Python)

%o from itertools import combinations

%o def a(n):

%o s, eset = str(n), set()

%o for i in range(len(s)):

%o for j in range(i+1, len(s)+1):

%o if s[j-1] in "02468":

%o if len(s[i:j]) <= 2 and j-i < len(s):

%o eset.add(int(s[i:j]))

%o else:

%o middle = s[i+1:j-1]

%o for k in range(len(middle)+1):

%o for c in combinations(middle, k):

%o t = s[i] + "".join(c) + s[j-1]

%o if len(t) < len(s):

%o eset.add(int(t))

%o return len(eset)

%o print([a(n) for n in range(105)]) # _Michael S. Branicky_, Mar 24 2021

%Y Cf. A045888, A342845, A342846.

%K base,easy,nonn

%O 0,21

%A _Felice Russo_

%E More terms from _Fabian Rothelius_, Feb 08 2001

%E a(102) and a(104) corrected by _Reinhard Zumkeller_, Jul 19 2011

%E a(102) and a(104) reverted to original values by _Sean A. Irvine_, Mar 23 2021