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

Smallest prime beginning and ending in exactly n 1's and containing at least one digit != 1.
6

%I #18 Oct 02 2024 12:18:36

%S 2,101,11311,1114111,111181111,111110611111,1111118111111,

%T 111111151111111,111111110911111111,11111111128111111111,

%U 111111111161111111111,111111111110911111111111,11111111111104111111111111,1111111111111031111111111111,11111111111111611111111111111,11111111111111173111111111111111

%N Smallest prime beginning and ending in exactly n 1's and containing at least one digit != 1.

%C a(499) has 1001 digits. - _Michael S. Branicky_, Oct 02 2024

%H Michael S. Branicky, <a href="/A068160/b068160.txt">Table of n, a(n) for n = 0..498</a>

%e a(2) = 11311 is a prime that starts with 11 and ends in 11 (two 1's).

%o (Python)

%o from gmpy2 import is_prime

%o def a(n):

%o suffix, d = (10**n-1)//9, 2*n+1

%o while True:

%o prefix = 10**(d-n)*suffix

%o for mid in range(0, 10**(d-n), 10**n):

%o s = str(mid//10**n)

%o if s[0] == "1" or s[-1] == "1": continue

%o t = prefix + mid + suffix

%o if is_prime(t): return t

%o d += 1

%o print([a(n) for n in range(16)]) # _Michael S. Branicky_, Oct 02 2024

%Y Cf. A366416.

%K nonn,base

%O 0,1

%A _Amarnath Murthy_, Feb 24 2002

%E Corrected and extended by _Sascha Kurz_, Jan 03 2003

%E More precise name and more terms from _Hugo Pfoertner_, Oct 11 2023

%E a(0) = 2 inserted by _Michael S. Branicky_, Oct 02 2024