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); ); ); } b = vector(10 000) u = 1 n = 0 a = [0] emit(v) = { n++; if (v <= #b, b[v] = n; while (b[u], print (u " " b[u]); if (u++ > #b, quit; ); ); ); see(v); if (#a < n, a = concat(a, vector(#a)); ); a[n] = v; } { emit(1); emit(2); for (n = 2, oo, emit(v = look(a[n])); emit(look(gcd(v, a[n]))); ); } quit