big = 1 000 000 s = 0 S = [] unseen = 1 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++) \\ least k unseen / gcd(p, k) != 1 look(p) = { for (v = unseen, oo, if (!seen(v) && gcd(p, v)!=1, return (v); ); ); } n = 0 a = vector(5000) emit(v) = { print (n++ " " v); see(v); if (n <= #a, a[n] = v; ); } { emit(1); emit(2); for (n = 2, #a, emit(v = look(a[n])); emit(look(gcd(v, a[n]))); ); } quit