explore(b, s, i) = { my (x=0); if (i>#b, x = 2^s, for (j=i, #b, x = bitor(x, explore(b, s+fromdigits(b[i..j],2), j+1)); ); ); x } a(n) = { hammingweight(explore(binary(n), 0, 1)) } for (n=1, 2^14, print (n " " a(n))) quit