login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Primes that remain prime when a single digit 9 is inserted between any two consecutive digits or as the leading or trailing digit.
27

%I #14 Oct 22 2016 14:46:44

%S 7,19,37,41,199,239,311,587,661,941,967,1009,1997,4993,4999,5393,5651,

%T 6911,9109,9397,9679,9829,19417,20233,22549,27397,29389,31387,39989,

%U 71419,71569,90599,91951,95369,97103,98909,99023,160009,225919,267389,313991,328849

%N Primes that remain prime when a single digit 9 is inserted between any two consecutive digits or as the leading or trailing digit.

%H Harvey P. Dale, <a href="/A215421/b215421.txt">Table of n, a(n) for n = 1..100</a>

%e 31387 is prime and also 313879, 313897, 313987, 319387, 391387, 931387.

%p A215421:=proc(q,x)

%p local a,b,c,d,i,n,ok;

%p for n from 1 to q do

%p a:=ithprime(n); b:=0; while a>0 do b:=b+1; a:=trunc(a/10); od;

%p a:=ithprime(n); ok:=1;

%p for i from 0 to b do

%p c:=a+9*10^i*trunc(a/10^i)+10^i*x; if not isprime(c) then ok:=0; break; fi;

%p od;

%p if ok=1 then print(ithprime(n)); fi;

%p od; end:

%p A215421(1000,9);

%t Select[Prime[Range[30000]],AllTrue[FromDigits/@Table[Insert[ IntegerDigits[ #],9,n],{n, IntegerLength[ #]+1}],PrimeQ]&] (* The program uses the AllTrue function from Mathematica version 10 *) (* _Harvey P. Dale_, Oct 22 2016 *)

%Y Cf. A215417-A215420

%K nonn,base

%O 1,1

%A _Paolo P. Lava_, Aug 10 2012