big = 10^6 \\ first big value small values = 0 \\ small values mask big values = Set([]) \\ big values set see(v) = if (v < big, small values += 2^v, big values = set union(big values, Set([v]))) seen(v) = if (v < big, bit test(small values, v), set search(big values, v)) other(p) = my (m=[0]); \ my (p2=p); \ while (1, \ my (xm = []); \ for (i=1, #m, \ if (bit and(m[i], p2)==0, \ my (v=m[i]+p2); \ if (!seen(v/p), return (v/p)); \ xm = concat(xm, v); \ ); \ ); \ m = concat(m, xm); \ p2 *= 2; \ ); for (n=1, 10 000, a = other(n); print (n " " a); see(a)) quit