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++) other(x) = { for (v=unseen, oo, if (!seen(v) && gcd(x,v)==1, return (v); ); ); } x = vector(10 000, n, 1) { for (n=1, #x, see(v=other(x[n])); print (n " " x[n]); for (m=n+1, min(#x, 2*n), x[m] *= v; ); ); } quit