OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
Carlos Rivera, Puzzle 20. Reversible Primes, The Prime Puzzles and Problems Connection.
EXAMPLE
31 - 13 = 18, 71 - 17 = 54, 73 - 37 = 36 (distance between lesser emirps and their reversals).
MAPLE
rev:= proc(n) local L, i;
L:= convert(n, base, 10);
add(L[-i]*10^(i-1), i=1..nops(L));
end proc:
f:= proc(p) local r;
if not isprime(p) then return NULL fi;
r:= rev(p);
if r > p and isprime(r) then r-p else NULL fi
end proc:
map(f, [seq(i, i=11 .. 10^4, 2)]); # Robert Israel, Dec 28 2023
MATHEMATICA
f[n_] := IntegerReverse[n] - n; Map[f, Select[Range[1500], f[#] > 0 && PrimeQ[#] && PrimeQ @ IntegerReverse[#] &]] (* Amiram Eldar, Sep 08 2021 *)
PROG
(PARI) rev(p) = fromdigits(Vecrev(digits(p))); \\ A004086
lista(nn) = {my(list = List()); forprime (p=1, nn, my(q=rev(p)); if ((q>p) && isprime(q), listput(list, q-p)); ); Vec(list); } \\ Michel Marcus, Sep 07 2021
(Python)
from sympy import isprime, nextprime
def aupton(terms):
alst, p = [], 2
while len(alst) < terms:
revp = int(str(p)[::-1])
if p < revp and isprime(revp):
alst.append(revp - p)
p = nextprime(p)
return alst
print(aupton(49)) # Michael S. Branicky, Sep 08 2021
CROSSREFS
KEYWORD
AUTHOR
George Bull, Aug 20 2021
EXTENSIONS
Better name and more terms from Jon E. Schoenfield, Aug 20 2021
STATUS
approved