OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..169
EXAMPLE
a(6) = 1021 is a term because it is prime, the next prime is 1031, and the reverse of 1021*1031 = 1052651 is 1562501 = 1301*1201.
MAPLE
revdigs:= proc(n) local L, i, m;
L:= convert(n, base, 10);
m:= nops(L);
add(L[i]*10^(m-i), i=1..m)
end proc:
R:= NULL: count:= 0:
q:= 2: qr:= 2:
while count < 50 do
p:= q; pr:= qr;
q:= nextprime(q); qr:= revdigs(q);
if pr*qr = revdigs(p*q) then
count:= count+1; R:= R, p;
fi
od:
R;
MATHEMATICA
seqQ[p_] := PrimeQ[p] && Module[{r = IntegerReverse, q = NextPrime[p]}, r[p*q] == r[p] * r[q]]; Select[Range[2.2*10^6], seqQ] (* Amiram Eldar, Jan 05 2022 *)
PROG
(PARI) R(n) = fromdigits(Vecrev(digits(n))); \\ A004086
isok(p) = if (isprime(p), my(q=nextprime(p+1)); R(p*q) == R(p)*R(q)); \\ Michel Marcus, Jan 05 2022
(Python)
from itertools import islice
from sympy import isprime, nextprime
def R(n): return int(str(n)[::-1])
def agen(): # generator of terms
p, pr = 2, 2
while True:
q = nextprime(p)
qr = R(q)
if R(p*q) == pr * qr:
yield p
p, pr = q, qr
print(list(islice(agen(), 38))) # Michael S. Branicky, Jan 05 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
J. M. Bergot and Robert Israel, Jan 05 2022
STATUS
approved
