Sean A. Irvine, <a href="/A045887/b045887_1.txt">Table of n, a(n) for n = 0..10000</a>
Sean A. Irvine, <a href="/A045887/b045887_1.txt">Table of n, a(n) for n = 0..10000</a>
proposed
approved
editing
proposed
(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
Number of distinct even numbers visible as proper substrings subsequences of n.
Reinhard Zumkeller, Sean A. Irvine, <a href="/A045887/b045887_1.txt">Table of n, a(n) for n = 0..10000</a> [Corrected by _Sean A. Irvine_, Mar 23 2021]
(Haskell)
import Data.List (isInfixOf)
a045887 n = length $ filter (`isInfixOf` (show n)) $ map show [0, 2..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 "02468" and j-i < len(s): # even and proper substring
eset.add(int(s[i:j]))
return len(eset)
print([a(n) for n in range(105)]) # Michael S. Branicky, Mar 23 2021
if s[i] != "0" or j-i == 1: # don't count if starts with 0 and not 0
eset.add(int(s[i:j]))
(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 "02468" and j-i < len(s): # even and proper substring
if s[i] != "0" or j-i == 1: # don't count if starts with 0 and not 0
eset.add(s[i:j])
return len(eset)
print([a(n) for n in range(105)]) # Michael S. Branicky, Mar 23 2021
proposed
editing
editing
proposed
Number of distinct even numbers visible as proper substrings of n.
proposed
editing