big = 1 000 000 s = 0 S = Set([]) unseen = 1 seen(v) = if (v < big, bit test(s, v), set search(S, v)) see(v) = if (v < big, s = bit or(s, 2^v), S = set union(S, Set([v]))); while (seen(unseen), unseen++) \\ first unseen number v such that p AND v = 0 cc = [0] avoid(p) = { my (w=1, b, c); for (e=0, oo, if (!bittest(p, e), if (#cc==w, cc=concat(cc, vector(#cc)); ); b = 2^e; for (k=1, w, c = cc[w+k] = b+cc[k]; if (!seen(c), return (c); ); ); w*=2; ); ); } { m = 0; x = vector(50 000); for (n=0, #x, see(v=if (n, avoid(x[n]), 0)); if (hammingweight(v)!=1, print (m++ " " n); ); for (m=n+1, min(#x, 2*n), x[m] = bitor(x[m], v); ); ); } quit