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.

A377295 a(n) is the least n-digit prime which is the sum of the squares of six consecutive nonnegative numbers, or -1 if no such prime exists.

Original entry on oeis.org

-1, -1, 139, 1279, 15319, 102199, 1011079, 10054399, 100687891, 1000860859, 10004248351, 100048116199, 1000245990631, 10000171206199, 100000029166651, 1000000001958499, 10000010020185919, 100000022659152859, 1000000088358667051, 10000000476596855539, 100000000728055460899
Offset: 1

Views

Author

Jean-Marc Rebert, Oct 23 2024

Keywords

Comments

From Robert Israel, Dec 23 2024: (Start)
a(n) is the first n-digit prime, if any, in A027867.
a(n) == 1 or 19 (mod 30) if it is not -1. (End)

Examples

			139 is the smallest 3-digit prime number that can be expressed as the sum of the squares of six consecutive numbers. Specifically, the sum of the squares of the numbers from 2 to 7 is 139:
Sum_{i=1..6} (1+i)^2 = 2^2 + 3^2 + 4^2 + 5^2 + 6^2 + 7^2 = 4 + 9 + 16 + 25 + 36 + 49 = 139.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local p,k;
     for k from ceil(sqrt(6*10^(n-1)-105)/6 - 5/2) do
       p:= 55 + 30*k + 6*k^2;
       if p >= 10^n then return -1 fi;
       if isprime(p) then return p fi;
      od
    end proc:
    f(1):= -1: f(2):= -1:
    map(f, [$1..25]); # Robert Israel, Dec 23 2024
  • Python
    from math import isqrt
    from sympy import isprime
    from itertools import count
    def f(m): return sum((m+i)**2 for i in range(6))
    def a(n):
        b = 10**(n-1)
        m = isqrt(b//6) - 5
        return next(t for i in count(m) if (t:=f(i)) >= b and isprime(t))
    print([a(n) for n in range(3, 23)]) # Michael S. Branicky, Oct 25 2024