login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A217047 Primes that remain prime when a single "8" digit is inserted between any two adjacent digits. 9

%I #21 Sep 08 2022 08:46:04

%S 11,23,47,83,131,173,179,233,353,389,521,569,641,683,839,887,911,971,

%T 983,1229,1289,1913,2087,2663,2837,2879,3329,3671,3677,3803,3821,4259,

%U 4409,4817,4871,4889,5237,5477,5693,6449,6581,6863,7283,7487,7583,7823,7853

%N Primes that remain prime when a single "8" digit is inserted between any two adjacent digits.

%H Paolo P. Lava, <a href="/A217047/b217047.txt">Table of n, a(n) for n = 1..200</a>

%e 325421 is prime and also 3254281, 3254821, 3258421, 3285421 and 3825421.

%p with(numtheory);

%p A217044:=proc(q,x)

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

%p for n from 5 to q do

%p a:=ithprime(n); b:=0;

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

%p for i from 1 to b-1 do

%p c:=a+9*10^i*trunc(a/10^i)+10^i*x;

%p if not isprime(c) then ok:=0; break; fi; od;

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

%p od; end:

%p A217044(100000,8)

%o (PARI) is(n)=my(v=concat([""],digits(n)));for(i=2,#v-1,v[1]=Str(v[1], v[i]); v[i]=8;if(i>2,v[i-1]="");if(!isprime(eval(concat(v))), return(0)));isprime(n) \\ _Charles R Greathouse IV_, Sep 25 2012

%o (Magma) [p: p in PrimesInInterval(11,8000) | forall{m: t in [1..#Intseq(p)-1] | IsPrime(m) where m is (Floor(p/10^t)*10+8)*10^t+p mod 10^t}]; // _Bruno Berselli_, Sep 26 2012

%o (Python)

%o from sympy import isprime, primerange

%o def ok(p):

%o if p < 10: return False

%o s = str(p)

%o return all(isprime(int(s[:i] + "8" + s[i:])) for i in range(1, len(s)))

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

%o print(aupto(7854)) # _Michael S. Branicky_, Nov 23 2021

%Y Cf. A050674, A050711-A050719, A069246, A159236, A215417, A215419-A215421, A217044-A217046, A217062-A217065.

%K nonn,base

%O 1,1

%A _Paolo P. Lava_, Sep 25 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 18 20:35 EDT 2024. Contains 376002 sequences. (Running on oeis4.)