login
Primes p such that the concatenation p987654321 is prime.
2

%I #24 Sep 08 2022 08:46:06

%S 97,107,149,179,193,233,271,359,421,439,449,457,491,499,547,557,593,

%T 673,677,701,769,821,839,947,971,1019,1021,1051,1069,1087,1091,1093,

%U 1103,1117,1163,1297,1301,1307,1327,1399,1409,1439,1453,1483,1493,1579,1597,1609

%N Primes p such that the concatenation p987654321 is prime.

%C Primes in A232766.

%H Harvey P. Dale, <a href="/A232767/b232767.txt">Table of n, a(n) for n = 1..1000</a>

%e 107 is a member of this sequence because 107 is prime and 107987654321 is prime.

%t With[{r=Range[9,1,-1]},Select[Prime[Range[500]], PrimeQ[FromDigits[ Join[ IntegerDigits[#],r]]]&]] (* _Harvey P. Dale_, Jul 31 2014 *)

%o (Python)

%o from sympy import isprime

%o {print(n,end=', ') for n in range(10**4) if isprime(n) and isprime(int(str(n)+"987654321"))}

%o # Simplified by _Derek Orr_, Apr 10 2015

%o (PARI) forprime(p=1,10^4,if(isprime(eval(concat(Str(p),"987654321"))),print1(p,", "))) \\ _Derek Orr_, Apr 10 2015

%o (Magma) [NthPrime(n): n in [0..500] | IsPrime(Seqint(Intseq(987654321) cat Intseq(NthPrime(n))))]; // _Vincenzo Librandi_, Apr 11 2015

%Y Cf. A232766, A104914, A104915.

%K nonn,base

%O 1,1

%A _Derek Orr_, Nov 29 2013