uptoqdigits(n) = { res = List(); for(i = 11, n, withqdigits(i); ); Set(res); } withqdigits(n) = { my(i, j, q, r, c); qd = n-10; forstep(i = 1, 10^qd - 1, 2, for(j = 1, qd, q = i \ 10^j; r = i % 10^j; c = q * 10^(10 + j) + 9876543210 * 10^j + r; if(isprime(c) && isprime(fromdigits(Vecrev(digits(c)))), print1(c", "); listput(res, c); ) ) ) }