A377294 a(n) is the least n-digit prime which is the sum of the squares of three consecutive numbers, or -1 if no such prime exists.
5, 29, 149, 1877, 11909, 100469, 1026677, 10013789, 100676549, 1000611509, 10007613149, 100003082789, 1000092600389, 10000275414869, 100000426365677, 1000004865589109, 10000013191662677, 100000034139489269, 1000000221045632669, 10000000313838962309, 100000002116695737029
Offset: 1
Examples
29 is the smallest 2-digit prime number that can be expressed as the sum of the squares of three consecutive numbers. Specifically, the sum of the squares of the numbers from 2 to 4 is 29: Sum_{i=1..3} (1+i)^2 = 2^2 + 3^2 + 4^2 = 4 + 9 + 16 = 29.
Programs
-
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(3)) def a(n): b = 10**(n-1) m = isqrt(b//3) - 2 m += m&1 # note: m must be even for f(m) to be odd return next(t for i in count(m, 2) if (t:=f(i)) >= b and isprime(t)) print([a(n) for n in range(2, 22)]) # Michael S. Branicky, Oct 25 2024