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.

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.

This page as a plain text file.
%I A377294 #34 Nov 28 2024 10:57:41
%S A377294 5,29,149,1877,11909,100469,1026677,10013789,100676549,1000611509,
%T A377294 10007613149,100003082789,1000092600389,10000275414869,
%U A377294 100000426365677,1000004865589109,10000013191662677,100000034139489269,1000000221045632669,10000000313838962309,100000002116695737029
%N 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.
%e A377294 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.
%o A377294 (Python)
%o A377294 from math import isqrt
%o A377294 from sympy import isprime
%o A377294 from itertools import count
%o A377294 def f(m): return sum((m+i)**2 for i in range(3))
%o A377294 def a(n):
%o A377294     b = 10**(n-1)
%o A377294     m = isqrt(b//3) - 2
%o A377294     m += m&1  # note: m must be even for f(m) to be odd
%o A377294     return next(t for i in count(m, 2) if (t:=f(i)) >= b and isprime(t))
%o A377294 print([a(n) for n in range(2, 22)]) # _Michael S. Branicky_, Oct 25 2024
%Y A377294 Primes in A120328.
%Y A377294 Cf. A376992.
%K A377294 nonn,base
%O A377294 1,1
%A A377294 _Jean-Marc Rebert_, Oct 23 2024