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

Original entry on oeis.org

11, 11, 1114111, 111181111, 111110611111, 1111118111111, 111111151111111, 111111110911111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111, 1111111111111111111
Offset: 1

Views

Author

Robert Israel, Oct 10 2023

Keywords

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

Examples

			a(3) = 1114111 which is prime and starts and ends with 3 1's.
		

Crossrefs

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