login
A366416
a(n) is the first prime that starts and ends with at least n 1's (in base 10).
2
11, 11, 1114111, 111181111, 111110611111, 1111118111111, 111111151111111, 111111110911111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111
OFFSET
1,1
COMMENTS
The initial and final strings of 1's are allowed to overlap.
If k is in A004023 and (k+1)/2 <= j <= k, then a(j) = (10^k-1)/9 (unless it is (10^i-1)/9 for some i < k where i is in A004023 and (i+1)/2 <= j <= i).
EXAMPLE
a(3) = 1114111 which is prime and starts and ends with 3 1's.
MAPLE
f:= proc(n) local x, s, d;
for d from n to 2*n-1 do
if isprime((10^d-1)/9) then return (10^d-1)/9 fi
od;
s:= (10^n-1)/9;
for d from n do
for x from 10^d*s + s by 10^n to 10^d*(s+1) do
if isprime(x) then return x fi
od od
end proc:
map(f, [$1..20]);
PROG
(Python)
from gmpy2 import is_prime
def a(n):
t = (10**n-1)//9
for d in range(n, 2*n):
if is_prime(t): return t
t = 10*t + 1
suffix = (10**n-1)//9
d = 2*n
while True:
prefix = 10**(d-n)*suffix
for mid in range(0, 10**(d-n), 10**n):
t = prefix + mid + suffix
if is_prime(t): return t
d += 1
print([a(n) for n in range(1, 18)]) # Michael S. Branicky, Oct 10 2023
CROSSREFS
Sequence in context: A280838 A140105 A265715 * A178496 A186433 A342076
KEYWORD
nonn,base,look
AUTHOR
Robert Israel, Oct 10 2023
STATUS
approved