big = 1 000 000 s = 0 S = [] unseen = 0 seen(v) = if (v < big, bittest(s, v), setsearch(S, v)) see(v) = if (v < big, s = bitor(s, 2^v), S = setunion(S, [v])); while (seen(unseen), unseen++) { see(0); a = vector(10 000); u = 1; p = 2; q = 3; for (n = 1, oo, if (n==1, v = 1, Mod(unseen, p) == Mod(v, p), v = unseen, forstep (w = (v%p) + (unseen\p)*p, oo, p, if (Mod(w, q) == Mod(unseen, q), v = w; break; ); ); ); see(v); if (v <= #a, a[v] = n; while (a[u], print (u " " a[u]); if (u++ > #a, break (2); ); ); ); if (n>1, p = q; q = nextprime(q+1); ); ); } quit