[go: up one dir, main page]

login
Primes whose reversal - 1 is also prime.
3

%I #18 Sep 08 2022 08:45:48

%S 3,23,41,47,83,89,233,251,257,281,401,461,491,809,821,827,839,857,863,

%T 887,2003,2069,2081,2099,2153,2213,2237,2267,2333,2351,2381,2393,2399,

%U 2477,2591,2633,2657,2711,2741,2753,2789,2819,2879,2909,2939,2957,2963

%N Primes whose reversal - 1 is also prime.

%H Vincenzo Librandi, <a href="/A167216/b167216.txt">Table of n, a(n) for n = 1..1000</a>

%e 23 is in the sequence because 23 is prime and 32 - 1 = 31 is prime.

%p reverse:= proc(n)

%p local L,j;

%p L:= convert(n,base,10);

%p add(L[j]*10^(nops(L)-j),j=1..nops(L))

%p end proc:

%p select(n -> isprime(n) and isprime(reverse(n)-1), [$1..10000]); # _Robert Israel_, Jul 11 2014

%t Select[Prime[Range[5000]], PrimeQ[FromDigits[Reverse[IntegerDigits[#]]] - 1] &] (* _Vincenzo Librandi_, Jul 11 2014 *)

%o (Magma) [p: p in PrimesInInterval(2, 3000) | IsPrime(q-1) where q is Seqint(Reverse(Intseq(p)))]; // _Vincenzo Librandi_, Jul 11 2014

%o (Python)

%o from sympy import isprime, primerange

%o def ok(p): return isprime(int(str(p)[::-1]) - 1)

%o print([p for p in primerange(1, 3000) if ok(p)]) # _Michael S. Branicky_, Mar 23 2021

%o (PARI) isok(p) = isprime(p) && isprime(fromdigits(Vecrev(digits(p)))-1); \\ _Michel Marcus_, Mar 23 2021

%Y Cf. similar sequences listed in A243457.

%K nonn,base

%O 1,1

%A _Claudio Meller_, Oct 30 2009

%E Comment changed to an Example by _Robert Israel_, Jul 11 2014