login
Primes not at the center of a 3 X 3 magic square of primes.
4

%I #16 Feb 16 2016 17:39:40

%S 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,61,67,79,83,97,101,107,

%T 113,163,181,197,199,223,229,233,277,313,317,331,433,439,457,569,859

%N Primes not at the center of a 3 X 3 magic square of primes.

%C The "magic sum" is always thrice the central entry.

%C There are no other terms < 5000.

%C There are no other terms < 100000. - _Robert Israel_, Feb 16 2016

%H <a href="/index/Mag#magic">Index entries for sequences related to magic squares</a>

%p N:= 10000: # to get all terms <= N

%p P:= select(isprime,{seq(p,p=3..2*N,2)}):

%p count:= 1:

%p A[count]:= 2:

%p for ic from 1 while P[ic] <= N do

%p c:= P[ic];

%p V:= map(`-`,P[ic+1..-1],c) intersect map(t -> c-t, P[1..ic-1]);

%p nv:= nops(V);

%p VV:= {seq(seq(V[j]-V[i],j=i+1..nv),i=1..nv-1)} intersect V;

%p nvv:= nops(VV);

%p found:= false;

%p for ia from 1 to nvv while not found do

%p a:= VV[ia];

%p for ib from ia+1 to nvv while VV[ib] < c - a do

%p b:= VV[ib];

%p if b <> 2*a and {c-a-b,c-a+b,c-b+a,c+a+b} subset P then

%p found:= true;

%p break

%p fi

%p od

%p od:

%p if not found then

%p count:= count+1;

%p A[count]:= c;

%p fi

%p od:

%p seq(A[i],i=1..count); # _Robert Israel_, Feb 16 2016

%Y Cf. A073473. A magic square with 59 at center is given in A024351.

%K nonn

%O 1,1

%A _David W. Wilson_, Aug 25 2002