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 avoid(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); for (n = 1, #a, emit(v = avoid(a[n])); emit(avoid(v * a[n])); ); } quit