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++) { div = vector(10 000); d = 0; for (n=1, #div, if (div[n]==0, v=unseen, forstep (w=ceil(unseen/div[n])*div[n], oo, div[n], if (!seen(w), v=w; break; ); ); ); if (d<#div, t = if (v==1, [1], factor(v)[,1]~); for (k=1, #t, div[d++] = t[k]; if (d==#div, break; ); ); ); print (n " " v); see(v); ); } quit