OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..1923 (terms 1..300 from Paolo P. Lava)
EXAMPLE
4083 is not prime but 40853, 40583, 45083 and 54083 are all primes.
MAPLE
with(numtheory);
A216167:=proc(q, x)
local a, b, c, i, n, ok;
for n from 1 to q do
if not isprime(n) then
a:=n; b:=0; while a>0 do b:=b+1; a:=trunc(a/10); od; a:=n; ok:=1;
for i from 1 to b 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(n); fi;
fi;
od; end:
A216167(1000, 5);
MATHEMATICA
Select[Range[6000], CompositeQ[#]&&AllTrue[FromDigits/@Table[Insert[IntegerDigits[#], 5, p], {p, IntegerLength[#]}], PrimeQ]&] (* Harvey P. Dale, Oct 02 2022 *)
PROG
(Magma) [n: n in [1..6000] | not IsPrime(n) and forall{m: t in [1..#Intseq(n)] | IsPrime(m) where m is (Floor(n/10^t)*10+5)*10^t+n mod 10^t}]; // Bruno Berselli, Sep 03 2012
(Python)
from sympy import isprime
def ok(n):
if n < 2 or n%10 not in {1, 3, 7, 9} or isprime(n): return False
s = str(n)
return all(isprime(int(s[:i] + '5' + s[i:])) for i in range(len(s)))
print(list(filter(ok, range(5698)))) # Michael S. Branicky, Sep 21 2021
CROSSREFS
KEYWORD
AUTHOR
Paolo P. Lava, Sep 03 2012
STATUS
approved