login
First of n^2 consecutive odd primes whose sum (=S) is divisible by n and S/n == n (mod 2).
1

%I #13 Jul 20 2023 12:44:23

%S 3,5,23,5,13,7,7,79,37,23,67,89,13,89,131,31,71,47,43,73,277,353,41,

%T 67,127,223,79,13,193,5,23,43,5,67,3,19,5,59,59,653,19,19,97,409,5,

%U 383,29,137,379,349,653,1187,47,41,37,17,619,89,283,283,43,479,191

%N First of n^2 consecutive odd primes whose sum (=S) is divisible by n and S/n == n (mod 2).

%C A necessary condition for the existence of a magic square consisting of n^2 consecutive odd primes.

%H Robert Israel, <a href="/A064187/b064187.txt">Table of n, a(n) for n = 1..1000</a>

%e a(5)=13 since 13+17+ ... +113 = 1565 = 5*313 and 313 == 5 (mod 2).

%p P:= select(isprime, [seq(i,i=3..10^6,2)]):

%p nP:= nops(P):

%p PS:= [0,op(ListTools:-PartialSums(P))]:

%p f:= proc(n) local i,s;

%p for i from 1 to nP+1-n^2 do

%p s:= PS[i+n^2]-PS[i];

%p if s mod n = 0 and (s/n - n) mod 2= 0 then return P[i] fi

%p od;

%p FAIL

%p end proc;

%p map(f, [$1..100]); # _Robert Israel_, Jul 18 2023

%o (PARI) for(n=1,50,k=2; m=n^2; aflag=0; while(k+m<=500000&&aflag==0,s=0; for(x=k,k+m-1,s=s+prime(x)); if(s%n==0&&(s/n)%2==n%2,print1(prime(k), ", "); aflag=1); k++))

%Y Position of 3's gives A064013.

%K nonn

%O 1,1

%A H. K. Gottlob Maier (1korrago(AT)freenet.de), Sep 20 2001