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

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

%S 7,19,31,61,79,193,283,367,373,421,499,547,619,733,751,883,997,1021,

%T 1033,1039,1069,1153,1171,1279,1399,1483,1543,1567,1753,1831,1879,

%U 1951,1999,2083,2161,2179,2251,2281,2287,2503,2671,2707,2713,2767,2797,2953,3019

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

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

%e 323 is composite, 525 is composite, 727 is prime so a(1)=7.

%p q:= n-> isprime(parse(cat(n, 2, n))):

%p select(q, [ithprime(i)$i=1..500])[]; # _Alois P. Heinz_, Jun 17 2021

%t cq2Q[n_]:=Module[{idn=IntegerDigits[n]},PrimeQ[FromDigits[Join[idn,{2},idn]]]]; Select[Prime[Range[400]],cq2Q] (* _Harvey P. Dale_, Apr 17 2019 *)

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

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

%o (Python)

%o from sympy import isprime, primerange

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

%o print(list(filter(ok, primerange(1, 3020)))) # _Michael S. Branicky_, Jul 19 2021

%Y Cf. similar sequences listed in A249374.

%K nonn,base

%O 1,1

%A _Pierre CAMI_, Oct 27 2014