allocate mem(2^30) s = 0 unseen = 1 seen(v) = bittest(s, v) see(v) = s = bitor(s, 2^v); while (seen(unseen), unseen++) rad(n) = vecprod(factor(n)[,1]~) gpf(n) = if (n==1, 1, my (f=factor(n)); f[#f~,1]) { for (n = 1, 10 000, if (n==1, v = 1, n==2, v = 6, for (w=unseen, oo, if (!seen(w), if (omega(w)==1, see(w), gcd(pp, w)==1 && gcd(p, w)>1 && rad(p) % rad(w), v = w; break; ); ); ); ); see(v); print (n " " gpf(v)); [pp, p] = [p, v]; ); } quit