|
|
A359322
|
|
a(n) is the first prime p such that the average of the squares of n consecutive primes starting with p is prime.
|
|
3
|
|
|
3, 7, 7, 1627, 83, 7, 23, 7, 19, 17, 73, 281, 179, 257, 5, 43, 73, 43, 19, 67, 911, 193, 7, 1613, 139, 383, 7, 719, 113, 967, 31, 19, 211, 769, 149, 173, 13, 13, 59, 137, 23, 47, 89, 607, 61, 127, 61, 317, 1049, 1277, 547, 281, 317, 4157, 199, 107, 373, 149, 229, 367, 1489, 643, 563, 587, 263
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
2,1
|
|
COMMENTS
|
|
|
LINKS
|
|
|
EXAMPLE
|
a(3) = 7 because 7, 11, 13 are 3 consecutive primes and (7^2 + 11^2 + 13^2)/3 = 113 is prime, and 7 is the least prime that works.
|
|
MAPLE
|
f:= proc(n) local P, s, i;
P:= <seq(ithprime(i), i=1..n)>;
s:= add(P[i]^2, i=1..n)/n;
do
if s::integer and isprime(s) then return P[1] fi;
s:= s - P[1]^2/n;
P[1..-2] := P[2..-1]; P[n]:= nextprime(P[n]);
s:= s + P[n]^2/n;
od
end proc:
map(f, [$2..70]);
|
|
PROG
|
(Python)
from sympy import prime, isprime, nextprime, primerange
def a(n):
plst = list(primerange(2, prime(n)+1))
powsum = sum(p**2 for p in plst)
while True:
q, r = divmod(powsum, n)
if r == 0 and isprime(q): return plst[0]
powsum -= plst[0]**2
plst = plst[1:] + [nextprime(plst[-1])]
powsum += plst[-1]**2
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|