digrev:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
dcat:= proc(x, y) 10^(1+ilog10(y))*x+y end proc:
R:= 23: count:= 1: lastpp:= 3:
for d from 2 while count < 100 do
for i in [1, 3, 7, 9] while count < 100 do
for m from i*10^(d-1)+1 to (i+1)*10^(d-1)-1 while count < 100 do
for j from 0 to 9 while count < 100 do
x:= m*10^(d+1)+j*10^d+digrev(m);
if isprime(x) then
y:= dcat(lastpp, x);
lastpp:= x;
if isprime(y) then R:= R, y; count:= count+1 fi
fi
od od od od: