login
A357133
a(n) is the least prime that is the arithmetic mean of n consecutive primes.
1
5, 127, 79, 101, 17, 269, 491, 727, 53, 23, 71, 181, 29, 31, 37, 43, 563, 331, 883, 283, 173, 307, 157, 113, 353, 571, 347, 89, 263, 139, 179, 1201, 281, 1553, 137, 5167, 347, 563, 2083, 2087, 491, 1867, 353, 463, 1973, 199, 599, 4373, 149, 9929, 277, 463, 1259, 251, 397, 2897, 787, 263, 2161
OFFSET
3,1
LINKS
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