big = 1 000 000 s = 0 S = Set([]) unseen = 1 seen(v) = if (v < big, bit test(s, v), set search(S, v)) see(v) = if (v < big, s = bit or(s, 2^v), S = set union(S, Set([v]))); while (seen(unseen), unseen++) ok(x,y) = my (f=factor(x*y)); sum(i=1, #f~, hammingweight(bitxor(valuation(x,f[i,1]), valuation(y,f[i,1]))))==1 other(p) = { see(p); fordiv (p, d, if (!seen(d) && ok(p,d), return (d); ); ); forstep (m=2*p, oo, p, if (!seen(m) && ok(p,m), return (m); ); ); } v=1; for (n=1, 10 000, print (n " " v); v=other(v)) quit