login
Primes that yield another prime on placing a 9 on both sides (as leading and trailing digits).
7

%I #12 Nov 07 2022 13:18:37

%S 2,19,23,31,41,43,47,53,61,67,71,73,83,101,107,109,113,149,163,193,

%T 211,239,241,263,269,277,313,317,331,347,373,397,409,421,439,443,499,

%U 521,523,541,547,607,617,619,641,647,673,677,757,787,829,863,877,907,911

%N Primes that yield another prime on placing a 9 on both sides (as leading and trailing digits).

%H Robert Israel, <a href="/A069690/b069690.txt">Table of n, a(n) for n = 1..10000</a>

%e 241 belongs to this sequence as 92419 is also a prime.

%p filter:= proc(n) isprime(9+10*n+9*10^(2+ilog10(n))) end proc:

%p select(filter, [seq(ithprime(i),i=1..1000)]); # _Robert Israel_, Feb 02 2021

%t Select[ Range[2000], PrimeQ[ # ] && PrimeQ[ FromDigits[ Insert[ IntegerDigits[ # ], 9, {{1}, {-1}}]]] &]

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

%o (Python)

%o from sympy import isprime, primerange

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

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

%o print(aupto(911)) # _Michael S. Branicky_, Feb 19 2021

%Y Cf. A069687, A069688, A069689.

%K nonn,base

%O 1,1

%A _Amarnath Murthy_, Apr 06 2002

%E Edited and extended by _Robert G. Wilson v_, May 03 2002