OFFSET
1,1
COMMENTS
If p is a term, so is A004086(p).
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(3) = 907 is a term because 907 and its digit reversal 709 are distinct primes, and (907*709) mod (907 + 709) = 1511 and its digit reversal 1151 are distinct primes.
MAPLE
rev:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L))
end proc:
filter:= proc(p) local q, r, s;
if not isprime(p) then return false fi;
q:= rev(p);
if q=p or not isprime(q) then return false fi;
r:= (p*q) mod (p+q);
if not isprime(r) then return false fi;
s:= rev(r);
s <> r and isprime(s)
end proc:
select(filter, [seq(i, i=13..10^5, 2)]);
MATHEMATICA
emirpQ[p_] := (r = IntegerReverse[p]) != p && PrimeQ[p] && PrimeQ[r]; Select[Range[40000], emirpQ[#] && emirpQ[Mod[#*(r = IntegerReverse[#]), # + r]] &] (* Amiram Eldar, Sep 04 2022 *)
PROG
(Python)
from sympy import isprime
def emirp(n):
revn = int(str(n)[::-1])
return n != revn and isprime(n) and isprime(revn)
def ok(n):
if not emirp(n): return False
q = int(str(n)[::-1])
return emirp((n*q)%(n+q))
print([k for k in range(10**5) if ok(k)]) # Michael S. Branicky, Sep 04 2022
CROSSREFS
KEYWORD
nonn,base,less
AUTHOR
J. M. Bergot and Robert Israel, Sep 04 2022
STATUS
approved