OFFSET
1,1
LINKS
Robert Israel, Table of n, a(n) for n = 1..5000
EXAMPLE
71 is the first prime in the earliest sequence of 5 = 2 * 2 + 1 consecutive primes whose average is a prime, since (71 + 73 + 79 + 83 + 89)/5 = 79. Therefore a(2) = 71.
MAPLE
f:= proc(n) local L, i, s;
L:= [seq(ithprime(i), i=1..2*n+1)]:
s:= convert(L, `+`);
do
if s mod (2*n+1) = 0 and isprime(s/(2*n+1)) then return L[1] fi;
s:= s - L[1];
L:= [op(L[2..-1]), nextprime(L[-1])];
s:= s + L[-1];
od
end proc:
map(f, [$1..100]); # Robert Israel, Jul 17 2025
MATHEMATICA
f[n_] := Block[{k = 1}, While[ !PrimeQ[ Sum[ Prime[j], {j, k, 2n + k}]/(2n + 1)], k++ ]; Prime[k]]; Table[ f[n], {n, 52}] (* Robert G. Wilson v, Jun 21 2005 *)
Module[{prs=Prime[Range[25000]]}, Table[SelectFirst[Partition[ prs, 2n+1, 1], PrimeQ[ Mean[ #]]&], {n, 60}]][[All, 1]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Oct 25 2017 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph L. Pe, Jun 16 2005
EXTENSIONS
More terms from Robert G. Wilson v, Jun 21 2005
STATUS
approved
