OFFSET
0,3
COMMENTS
The subsequence does not need to consist of adjacent terms.
LINKS
Andrew Howroyd, Table of n, a(n) for n = 0..4096
Geeks for Geeks, Count Distinct Subsequences
FORMULA
EXAMPLE
a(4) = 5 because 4 = 100_2, and the distinct subsequences of 100 are 0, 1, 00, 10, 100.
Similarly a(7) = 3, because 7 = 111_2, and 111 has only three distinct subsequences: 1, 11, 111.
a(9) = 10: 9 = 1001_2, and we get 0, 1, 00, 01, 10, 11, 001, 100, 101, 1001.
PROG
(Python)
def a(n):
if n == 0: return 1
r, l = 1, [0, 0]
while n:
r, l[n%2] = 2*r - l[n%2], r
n >>= 1
return r - 1
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Orson R. L. Peters, Oct 15 2017
EXTENSIONS
Terms a(50) and beyond from Andrew Howroyd, Apr 27 2020
STATUS
approved