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”).

A217063
Primes that remain prime when a single "3" digit is inserted between any two adjacent decimal digits.
4
11, 17, 19, 23, 29, 31, 37, 41, 43, 61, 73, 79, 89, 97, 101, 103, 127, 167, 173, 181, 211, 233, 239, 251, 271, 283, 307, 331, 359, 373, 439, 491, 509, 523, 547, 599, 673, 709, 733, 769, 877, 887, 937, 941, 991, 1033, 1229, 1381, 1619, 1721, 1759, 1789, 1901
OFFSET
1,1
LINKS
Bruno Berselli, Table of n, a(n) for n = 1..1000 (first 275 terms from Paolo Lava)
EXAMPLE
212881 is prime and also 2128831, 2128381, 2123881, 213288 and 2312881.
MAPLE
with(numtheory);
A217063:=proc(q, x)
local a, b, c, i, n, ok;
for n from 5 to q do
a:=ithprime(n); b:=0; while a>0 do b:=b+1; a:=trunc(a/10); od; a:=ithprime(n); ok:=1;
for i from 1 to b-1 do
c:=a+9*10^i*trunc(a/10^i)+10^i*x; if not isprime(c) then ok:=0; break; fi; od;
if ok=1 then print(ithprime(n)); fi; od; end:
A217063(1000000, 3);
PROG
(Magma) [p: p in PrimesInInterval(11, 2000) | forall{m: t in [1..#Intseq(p)-1] | IsPrime(m) where m is (Floor(p/10^t)*10+3)*10^t+p mod 10^t}]; // Bruno Berselli, Sep 26 2012
(PARI) is(n)=my(v=concat([""], digits(n))); for(i=2, #v-1, v[1]=Str(v[1], v[i]); v[i]=3; if(i>2, v[i-1]=""); if(!isprime(eval(concat(v))), return(0))); isprime(n) \\ Charles R Greathouse IV, Sep 26 2012
(Python)
from sympy import isprime, primerange
def ok(p):
if p < 10: return False
s = str(p)
return all(isprime(int(s[:i] + "3" + s[i:])) for i in range(1, len(s)))
def aupto(limit): return [p for p in primerange(1, limit+1) if ok(p)]
print(aupto(1901)) # Michael S. Branicky, Nov 17 2021
KEYWORD
nonn,base
AUTHOR
Paolo P. Lava, Sep 26 2012
STATUS
approved