OFFSET
0,3
COMMENTS
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..3485
Antti Karttunen, Gatomorphisms and other excursions ... (Includes Scheme program)
Antti Karttunen, Newer version of the Scheme code collection
PROG
(Python)
def a005811(n): return bin(n^(n>>1))[2:].count("1")
def ok(n): # This function after Peter Luschny
B=bin(n)[2:] if n!=0 else 0
s=0
for b in B:
s+=1 if b=="1" else -1
if s<0: return 0
return s==0
def A(n): return [0] + [i for i in range(1, n + 1) if ok(i)]
l=A(200)
print([a005811(l[i])//2 for i in range(len(l))]) # Indranil Ghosh, May 21 2017
CROSSREFS
KEYWORD
nonn
AUTHOR
Antti Karttunen, Sep 03 2000
STATUS
approved