login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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

%I #27 Dec 23 2024 21:58:22

%S -1,-1,139,1279,15319,102199,1011079,10054399,100687891,1000860859,

%T 10004248351,100048116199,1000245990631,10000171206199,

%U 100000029166651,1000000001958499,10000010020185919,100000022659152859,1000000088358667051,10000000476596855539,100000000728055460899

%N 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.

%C From _Robert Israel_, Dec 23 2024: (Start)

%C a(n) is the first n-digit prime, if any, in A027867.

%C a(n) == 1 or 19 (mod 30) if it is not -1. (End)

%H Robert Israel, <a href="/A377295/b377295.txt">Table of n, a(n) for n = 1..996</a>

%e 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:

%e 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.

%p f:= proc(n) local p,k;

%p for k from ceil(sqrt(6*10^(n-1)-105)/6 - 5/2) do

%p p:= 55 + 30*k + 6*k^2;

%p if p >= 10^n then return -1 fi;

%p if isprime(p) then return p fi;

%p od

%p end proc:

%p f(1):= -1: f(2):= -1:

%p map(f, [$1..25]); # _Robert Israel_, Dec 23 2024

%o (Python)

%o from math import isqrt

%o from sympy import isprime

%o from itertools import count

%o def f(m): return sum((m+i)**2 for i in range(6))

%o def a(n):

%o b = 10**(n-1)

%o m = isqrt(b//6) - 5

%o return next(t for i in count(m) if (t:=f(i)) >= b and isprime(t))

%o print([a(n) for n in range(3, 23)]) # _Michael S. Branicky_, Oct 25 2024

%Y Cf. A027865, A027867, A376992.

%K sign,base

%O 1,3

%A _Jean-Marc Rebert_, Oct 23 2024