OFFSET
1,1
COMMENTS
a(n) is the least prime that is the start and end of sequences of 2*n+1 consecutive primes whose arithmetic means are their medians.
LINKS
Ruud H.G. van Tol, Table of n, a(n) for n = 1..80
EXAMPLE
a(3) = 211 because the 7 consecutive primes 179, 181, 191, 193, 197, 199, 211 ending at 211 have mean = median = 193 and the 7 consecutive primes 211, 223, 227, 229, 233, 239, 241 starting at 211 have mean = median = 229, and 211 is the first prime for which this works.
MAPLE
f:= proc(n)
local S, i;
S:= [seq](ithprime(i), i=1..4*n+1);
do
if convert(S[1..2*n+1], `+`) = (2*n+1)*S[n+1] and convert(S[2*n+1..4*n+1], `+`) = (2*n+1)*S[3*n+1] then
return S[2*n+1] fi;
S:= [op(S[2..-1]), nextprime(S[-1])]
od;
end proc:
map(f, [$1..35]);
PROG
(PARI) alist(N) = {my(r=vector(N), p=primes(4*N+1), t); while(t=Vec(select(x->!x, r, 1)), foreach(t, n, my(w=2*n+1); if(vecsum(p[1..w])==w*p[1+n] && vecsum(p[w..2*w-1])==w*p[w+n], r[n]=p[w])); p=primes([p[2], nextprime(p[#p]+1)])); r; } \\ Ruud H.G. van Tol, Jul 13 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Robert Israel, Jul 11 2024
STATUS
approved