login
Prime numbers Q such that the concatenation Q,9,Q is prime.
3

%I #37 Sep 08 2022 08:46:10

%S 7,13,19,41,43,47,61,67,71,73,79,83,89,107,137,149,173,179,211,229,

%T 269,277,281,283,379,401,431,443,491,523,547,557,577,599,607,613,619,

%U 647,683,691,823,863,877,919,977,1031,1069,1091,1151,1171,1213,1249,1259

%N Prime numbers Q such that the concatenation Q,9,Q is prime.

%H Pierre CAMI, <a href="/A249381/b249381.txt">Table of n, a(n) for n = 1..10000</a>

%e 393 is composite.

%e 595 is composite.

%e 797 is prime so a(1)=7.

%e 11911 is composite.

%e 13913 is prime so a(2)=13.

%t Select[Prime[Range[200]],PrimeQ[FromDigits[Join[IntegerDigits[#],{9}, IntegerDigits[ #]]]]&] (* _Harvey P. Dale_, Jul 25 2015 *)

%o (PARI) lista(nn) = {forprime(p=1, nn, if (isprime(eval(concat(concat(Str(p), 9), Str(p)))), print1(p, ", ")););} \\ _Michel Marcus_, Oct 27 2014

%o (Magma) [p: p in PrimesUpTo(3000) | IsPrime(Seqint(Intseq(p) cat [9] cat Intseq(p)))]; // _Vincenzo Librandi_, Oct 27 2014

%o (Python)

%o from sympy import isprime, primerange

%o def ok(p): swb = str(p); return isprime(int(swb + '9' + swb))

%o def aupto(lim): return [p for p in primerange(1, lim+1) if ok(p)]

%o print(aupto(1260)) # _Michael S. Branicky_, Jul 13 2021

%Y Cf. similar sequences listed in A249374.

%K nonn,base

%O 1,1

%A _Pierre CAMI_, Oct 27 2014