\\ save into a file and run with command "gp -q A328257.gp" s = 0 unseen = 1 seen(v) = bit test(s, v) see(v) = s = bit or(s, 2^v); while (seen(unseen), unseen++) { dup = []; for (n=1, M = 1 000 000, v=if(n==1, 1, fromdigits(Vecrev(digits(nextprime(1+v), n)), n)); if (v <= M, if (!seen(v), see(v), dup=setunion(dup,[v]); ); ); ); apply (v -> print (n++ " " v), dup); } quit