OFFSET
1,1
LINKS
Vincenzo Librandi, Table of n, a(n) for n = 1..1000
EXAMPLE
23 is in the sequence because 23 is prime and 32 - 1 = 31 is prime.
MAPLE
reverse:= proc(n)
local L, j;
L:= convert(n, base, 10);
add(L[j]*10^(nops(L)-j), j=1..nops(L))
end proc:
select(n -> isprime(n) and isprime(reverse(n)-1), [$1..10000]); # Robert Israel, Jul 11 2014
MATHEMATICA
Select[Prime[Range[5000]], PrimeQ[FromDigits[Reverse[IntegerDigits[#]]] - 1] &] (* Vincenzo Librandi, Jul 11 2014 *)
PROG
(Magma) [p: p in PrimesInInterval(2, 3000) | IsPrime(q-1) where q is Seqint(Reverse(Intseq(p)))]; // Vincenzo Librandi, Jul 11 2014
(Python)
from sympy import isprime, primerange
def ok(p): return isprime(int(str(p)[::-1]) - 1)
print([p for p in primerange(1, 3000) if ok(p)]) # Michael S. Branicky, Mar 23 2021
(PARI) isok(p) = isprime(p) && isprime(fromdigits(Vecrev(digits(p)))-1); \\ Michel Marcus, Mar 23 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Claudio Meller, Oct 30 2009
EXTENSIONS
Comment changed to an Example by Robert Israel, Jul 11 2014
STATUS
approved