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++) { for (n = 0, 10 000, if (n==0, v = 0, Mod(unseen, n) == Mod(v, n), v = unseen, forstep (w = (v%n) + (unseen\n)*n, oo, n, if (Mod(w, n+1) == Mod(unseen, n+1), v = w; break; ); ); ); see(v); print (n " " v); ); } quit