revdigs:= proc(n) local L, i; L:= convert(n, base, 10); add(L[-i]*10^(i-1), i=1..nops(L)) end proc:
isemirp:= proc(p) local r;
if not isprime(p) then return false fi;
r:= revdigs(p);
r <> p and isprime(r)
end proc:
g:= proc(n) local p, q, t, count;
count:= 0;
for t in select(`<`, numtheory:-divisors(n+1), floor(sqrt(n+1))) do
if isemirp(t-1) and isemirp((n+1)/t-1) then
count:= count+1;
fi
od;
count
end proc:
V:= Array(0..6): vcount:= 0:
p:= 2:
while vcount < 7 do
p:= nextprime(p);
d:= ilog10(p);
p1:= floor(p/10^d);
if p1=2 then p:= nextprime(3*10^d)
elif member(p1, {4, 5, 6}) then p:= nextprime(7*10^d)
elif p1=8 then p:= nextprime(9*10^d)
fi;
if isemirp(p) then
v:= g(p);
if V[v] = 0 then vcount:= vcount+1; V[v]:= p; fi;
fi
od:
convert(V, list);
|