A366416 a(n) is the first prime that starts and ends with at least n 1's (in base 10).
11, 11, 1114111, 111181111, 111110611111, 1111118111111, 111111151111111, 111111110911111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111
Offset: 1
Examples
a(3) = 1114111 which is prime and starts and ends with 3 1's.
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
Programs
-
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]);
-
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
Comments