OFFSET
0,3
COMMENTS
The next term is too large to include.
The actual sequence in binary is 0, 00, 0010, 00100110, ... The 0s at the start of each term are required for the sequence to work.
EXAMPLE
a(2) = 0010;
a(3) = (0010 + 0101 -> 00100110);
a(4) = (00100110 + 01010101 = 0010011000110110).
Full explanation:
Say we have the term 0010.
We get an equal length binary number of alternating 0s and 1s.
In this case it would be 0101, and we interlace them like so:
0 1 0 1
0010 + 0101 -> 0 0 1 0 -> 00100110
PROG
(Python)
def combine(a, b):
c = ''
for i in range(max(len(a), len(b))*2):
if i%2 == 0:
if len(a) > i/2:
c += (a[int(i/2)])
else:
if len(b) > i/2:
c += (b[int(i/2)])
return c
x = '0'
while True:
x = combine(combine(len(x)*'0', len(x)*'1')[:len(x)], x)
(Python)
from itertools import islice
def A348162(): # generator of terms
s = '0'
while True:
yield int(s, 2)
s = ''.join(x+y for x, y in zip('01'*((len(s)+1)//2), s))
(PARI) a(n) = my(ret=0, s=1); for(i=2, n, ret += 1<<s + ret<<(s<<=1)); ret; \\ Kevin Ryde, Nov 19 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Edward Green, Oct 03 2021
STATUS
approved