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.

A045888 Number of distinct odd numbers visible as proper subsequences of n.

This page as a plain text file.
%I A045888 #48 Apr 18 2025 21:39:22
%S A045888 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,
%T A045888 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,
%U A045888 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
%N A045888 Number of distinct odd numbers visible as proper subsequences of n.
%H A045888 Sean A. Irvine, <a href="/A045888/b045888.txt">Table of n, a(n) for n = 1..20000</a>
%H A045888 Sean A. Irvine, <a href="https://github.com/archmageirvine/joeis/blob/master/src/irvine/oeis/a045/A045888.java">Java program</a> (github).
%e A045888 The first nonzero entry is a(10) = 1 since we can see 1 as a proper subsequence of 10.
%e A045888 a(105) = 3 since we can see 1, 5, 15 (but not 105).
%e A045888 a(132) = 3 because we can see 1, 3, 13 (subsequences 12, 32 and 132 do not count as they are even and 132 also does not count as it does not come from a proper subsequence of digits of 132).
%t A045888 a[n_] := Count[Union[Most[Rest[Subsets[IntegerDigits[n]]]]], _?(First[#] > 0 && OddQ[Last[#]] &)]; Array[a, 100] (* _Amiram Eldar_, Apr 12 2025 *)
%o A045888 (Python)
%o A045888 from itertools import combinations
%o A045888 def a(n):
%o A045888   s, eset = str(n), set()
%o A045888   for i in range(len(s)):
%o A045888     for j in range(i+1, len(s)+1):
%o A045888       if s[j-1] in "13579":
%o A045888         if len(s[i:j]) <= 2 and j-i < len(s):
%o A045888           eset.add(int(s[i:j]))
%o A045888         else:
%o A045888           middle = s[i+1:j-1]
%o A045888           for k in range(len(middle)+1):
%o A045888             for c in combinations(middle, k):
%o A045888               t = s[i] + "".join(c) + s[j-1]
%o A045888               if len(t) < len(s):
%o A045888                 eset.add(int(t))
%o A045888   return len(eset)
%o A045888 print([a(n) for n in range(1, 105)]) # _Michael S. Branicky_, Mar 24 2021
%o A045888 (PARI) a(n) = {
%o A045888     my(d = digits(n), odds = List());
%o A045888     for(i = 1, #d,
%o A045888         if(bitand(d[i], 1),
%o A045888             forsubset(i-1, s,
%o A045888                 c = fromdigits(vector(#s, j, d[s[j]])) * 10+d[i];
%o A045888                 listput(odds, c))));
%o A045888     #Set(odds)-bitand(n,1)
%o A045888 } \\ _David A. Corneth_, Apr 13 2025
%Y A045888 Cf. A045887, A342845, A342846.
%K A045888 nonn,easy,base,nice
%O A045888 1,13
%A A045888 _Felice Russo_
%E A045888 More terms from Larry Reeves (larryr(AT)acm.org), Sep 28 2000
%E A045888 Revised by _Sean A. Irvine_, Mar 23 2021