OFFSET
1,1
COMMENTS
LINKS
Robert Israel, Table of n, a(n) for n = 1..495
S. Dutta et al, Infinitely many primes of the form 11...1 (k times) ... 11 ... 1 (k times, Mathematics StackExchange
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
KEYWORD
AUTHOR
Robert Israel, Oct 10 2023
STATUS
approved