OFFSET
3,1
LINKS
Robert Israel, Table of n, a(n) for n = 3..7000
EXAMPLE
a(5) = 79 because 79 is the average of the 5 consecutive primes 71, 73, 79, 83, 89, and 79 is the least prime that works.
MAPLE
P:= [seq(ithprime(i), i=1..10^5)]:
S:= ListTools:-PartialSums(P):
g:= proc(n) local k, r;
for k from 1 to 10^5-n do
r:= (S[k+n]-S[k])/n;
if r::integer and isprime(r) then return r fi
od;
-1
end proc:
map(g, [$3..100]);
MATHEMATICA
a={}; n=3; For[k=1, k<=1200, k++, If[PrimeQ[p=Sum[Prime[k+i], {i, 0, n-1}]/n], AppendTo[a, p]; n++; k=1]]; a (* Stefano Spezia, Sep 15 2022 *)
PROG
(Python)
from itertools import islice
from sympy import isprime, nextprime
def agen():
n, plst0 = 3, [2, 3, 5]
while True:
plst = plst0[:]
while True:
q, r = divmod(sum(plst), n)
if r == 0 and isprime(q): yield q; break
plst = plst[1:] + [nextprime(plst[-1])]
plst0.append(nextprime(plst0[-1]))
n += 1
print(list(islice(agen(), 60))) # Michael S. Branicky, Sep 14 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Sep 14 2022
STATUS
approved