cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A366416 a(n) is the first prime that starts and ends with at least n 1's (in base 10).

This page as a plain text file.
%I A366416 #61 Mar 28 2025 03:26:16
%S A366416 11,11,1114111,111181111,111110611111,1111118111111,111111151111111,
%T A366416 111111110911111111,1111111111111111111,1111111111111111111,
%U A366416 1111111111111111111,1111111111111111111,1111111111111111111,1111111111111111111,1111111111111111111,1111111111111111111,1111111111111111111
%N A366416 a(n) is the first prime that starts and ends with at least n 1's (in base 10).
%C A366416 The initial and final strings of 1's are allowed to overlap.
%C A366416 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).
%H A366416 Robert Israel, <a href="/A366416/b366416.txt">Table of n, a(n) for n = 1..495</a>
%H A366416 S. Dutta et al, <a href="https://math.stackexchange.com/questions/4784494/infinitely-many-primes-of-the-form-underbrace11-dots-1-k-text-times-dot">Infinitely many primes of the form 11...1 (k times) ... 11...1 (k times)</a>, Mathematics StackExchange
%e A366416 a(3) = 1114111 which is prime and starts and ends with 3 1's.
%p A366416 f:= proc(n) local x,s,d;
%p A366416   for d from n to 2*n-1 do
%p A366416      if isprime((10^d-1)/9) then return (10^d-1)/9 fi
%p A366416   od;
%p A366416   s:= (10^n-1)/9;
%p A366416   for d from n do
%p A366416     for x from 10^d*s + s by 10^n to 10^d*(s+1) do
%p A366416       if isprime(x) then return x fi
%p A366416   od od
%p A366416 end proc:
%p A366416 map(f, [$1..20]);
%o A366416 (Python)
%o A366416 from gmpy2 import is_prime
%o A366416 def a(n):
%o A366416     t = (10**n-1)//9
%o A366416     for d in range(n, 2*n):
%o A366416         if is_prime(t): return t
%o A366416         t = 10*t + 1
%o A366416     suffix = (10**n-1)//9
%o A366416     d = 2*n
%o A366416     while True:
%o A366416         prefix = 10**(d-n)*suffix
%o A366416         for mid in range(0,10**(d-n),10**n):
%o A366416             t = prefix + mid + suffix
%o A366416             if is_prime(t): return t
%o A366416         d += 1
%o A366416 print([a(n) for n in range(1,18)]) # _Michael S. Branicky_, Oct 10 2023
%Y A366416 Cf. A004023, A068160.
%K A366416 nonn,base,look
%O A366416 1,1
%A A366416 _Robert Israel_, Oct 10 2023