OFFSET
0,3
COMMENTS
Binary representation of n has 1's at positions specified by Connell sequence (A001614).
FORMULA
a(0)=0, a(n) = a(n-1) + 2^((2*n - floor((1/2)*(1 + sqrt(8*n - 7)))) - 1).
EXAMPLE
347=101011011 in binary, with 1's at positions 1,2,4,5,7,9.
PROG
(Python)
from itertools import count, islice
from math import isqrt
def A036571_gen(): # generator of terms
c = 0
for n in count(1):
yield c
c += 1<<(m:=n<<1)-(k:=isqrt(m))-int((m<<2)>(k<<2)*(k+1)+1)-1
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved