[go: up one dir, main page]

login
A045888
Number of distinct odd numbers visible as proper subsequences of n.
6
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,13
LINKS
Sean A. Irvine, Java program (github).
EXAMPLE
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.
a(132)=3 because we can see 1, 3, 13.
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 "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
CROSSREFS
KEYWORD
base,easy,nonn,nice
AUTHOR
EXTENSIONS
More terms from Larry Reeves (larryr(AT)acm.org), Sep 28 2000
Revised by Sean A. Irvine, Mar 23 2021
STATUS
approved