OFFSET
1,1
FORMULA
EXAMPLE
a(2) = 6: {0000, 0011, 0101, 1010, 1100, 1111}.
PROG
(Python)
from itertools import product
from functools import cache
@cache
def b(n): # length-2n binary strings of the form ww
return set(w+w for w in product(b"01", repeat=n))
def a(n):
return len(set(s+t for i in range(n) for s in b(i) for t in b(n-i)))
print([a(n) for n in range(1, 18)]) # Michael S. Branicky, Jan 23 2022
(Python) # bit-based version
from itertools import product
def b(n): # length-2n binary strings of the form ww
if n == 0: yield 0
for i in range(2**n):
yield (i << n) + i
def a(n):
st = set()
for i in range(n):
for w in b(i):
s = w << (2*(n-i))
for t in b(n-i):
st.add(s+t)
return len(st)
print([a(n) for n in range(1, 20)]) # Michael S. Branicky, Jan 25 2022
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Jeffrey Shallit, Jan 23 2022
EXTENSIONS
a(18)-a(21) from Michael S. Branicky, Jan 23 2022
a(22)-a(25) from Michael S. Branicky, Jan 25 2022
STATUS
approved