A268790
Magic sums of 3 X 3 magic squares composed of primes.
Original entry on oeis.org
177, 213, 219, 267, 309, 327, 381, 393, 411, 417, 447, 453, 471, 501, 519, 537, 573, 579, 633, 681, 717, 723, 753, 771, 789, 807, 813, 843, 849, 879, 921, 933, 1011, 1041, 1047, 1059, 1077, 1101, 1119, 1137, 1149, 1167, 1191, 1203, 1227, 1257, 1263, 1293
Offset: 1
Examples of 3 X 3 magic squares composed of primes.
.
+---+---+---+
| 17| 89| 71|
+---+---+---+
|113| 59| 5 |
+---+---+---+
| 47| 29|101|
+---+---+---+
The magic constant is 177 = a(1).
.
+---+---+---+
| 41| 89| 83|
+---+---+---+
|113| 71| 29|
+---+---+---+
| 59| 53|101|
+---+---+---+
The magic constant is 213 = a(2).
-
N:= 10000: # to get all terms <= N P:= select(isprime,{seq(p,p=3..2*N/3,2)}):
count:= 0:
for ic from 1 while P[ic] <= N/3 do
c:= P[ic];
V:= map(`-`,P[ic+1..-1],c) intersect map(t -> c-t, P[1..ic-1]);
nv:= nops(V);
VV:= {seq(seq(V[j]-V[i],j=i+1..nv),i=1..nv-1)} intersect V;
nvv:= nops(VV);
found:= false;
for ia from 1 to nvv while not found do
a:= VV[ia];
for ib from ia+1 to nvv while VV[ib] < c - a do
b:= VV[ib];
if b <> 2*a and {c-a-b,c-a+b,c-b+a,c+a+b} subset P then
found:= true;
count:= count+1;
A[count]:= 3*c;
break
fi
od
od:
od:
seq(A[i],i=1..count); # Robert Israel, Feb 16 2016
-
c=3;A268790_vec=3*vector(50,i,c=A320872_row(1,0,c+1)[2,2]) \\ Illustrates formula & comment. - M. F. Hasler, Oct 28 2018
-
is_A268790(c)={denominator(c/=3)==1&& isprime(c)&& forstep(a=2,c\2-1,2, isprime(c-a)&& isprime(c+a)&& forstep(b=2,c-2*a-2,2, isprime(c-2*a-b)&& isprime(c-a-b)&& isprime(c-b)&& isprime(c+b)&& isprime(c+a+b)&& isprime(c+2*a+b)&& return(1)))} \\ M. F. Hasler, Oct 28 2018
A320872
For all possible 3 X 3 magic squares made of primes, in order of increasing magic sum, list the lexicographically smallest representative of each equivalence class (modulo symmetries of the square), as a row of the 9 elements (3 rows of 3 elements each).
Original entry on oeis.org
17, 89, 71, 113, 59, 5, 47, 29, 101, 41, 89, 83, 113, 71, 29, 59, 53, 101, 37, 79, 103, 139, 73, 7, 43, 67, 109, 29, 131, 107, 167, 89, 11, 71, 47, 149, 43, 127, 139, 199, 103, 7, 67, 79, 163, 37, 151, 139, 211, 109, 7, 79, 67, 181, 43, 181, 157, 241, 127, 13, 97, 73, 211
Offset: 1
The first four rows,
17, 89, 71, 113, 59, 5, 47, 29, 101,
41, 89, 83, 113, 71, 29, 59, 53, 101,
37, 79, 103, 139, 73, 7, 43, 67, 109,
29, 131, 107, 167, 89, 11, 71, 47, 149, (...)
correspond to the following magic squares:
[ 17, 89, 71 ] [ 41, 89, 83] [ 37, 79, 103] [ 29, 131, 107]
[113, 59, 5 ] [113, 71, 29] [139, 73, 7 ] [167, 89, 11]
[ 47, 29, 101] [ 59, 53, 101] [ 43, 67, 109] [ 71, 47, 149]
The seventh and eighth row are two inequivalent magic squares for the same magic sum 3*127:
[ 43, 181, 157] [ 73, 151, 157]
[241, 127, 13] and [211, 127, 43] . (The pair (13, 241) is replaced
[ 97, 73, 211] [ 97, 103, 181] by (103, 151).)
Cf.
A320871: list of all inequivalent 3 X 3 magic squares (not only primes).
Cf.
A320873: the first row consisting of a set of consecutive primes.
Cf.
A268790: list of magic sums (= 3*(central term) = (row sum)/3), without duplicates.
-
A320872_row(N=10,show=1,c=3)={forprime(c=c,, forstep(d=c-3,2,-2, isprime(c-d)&& isprime(c+d)&& forstep(b=max(2*d+3-c,2),d-2,2, d!=2*b&& isprime(c-2*d+b)&& isprime(c-b)&& isprime(c-d+b)&& isprime(c+d-b)&& isprime(c+2*d-b)&& isprime(c+b)&& (S=[c-d,c+b,c+d-b;c+2*d-b,c,c-2*d+b;c-d+b,c-b,c+d])&& !(show&&print(S))&& !N--&& return(S))))} \\ The 3rd (optional) argument allows computation of the list starting with the first row having a central element >= c or equivalently a magic sum >= 3c. The multiple isprime() can all be avoided using simply vecmin(apply(isprime,S=[...])), but this is significantly slower, which matters if used as proposed in A268790.
A217568
Rows of the 8 magic squares of order 3 and magic sum 15, lexicographically sorted.
Original entry on oeis.org
2, 7, 6, 9, 5, 1, 4, 3, 8, 2, 9, 4, 7, 5, 3, 6, 1, 8, 4, 3, 8, 9, 5, 1, 2, 7, 6, 4, 9, 2, 3, 5, 7, 8, 1, 6, 6, 1, 8, 7, 5, 3, 2, 9, 4, 6, 7, 2, 1, 5, 9, 8, 3, 4, 8, 1, 6, 3, 5, 7, 4, 9, 2, 8, 3, 4, 1, 5, 9, 6, 7, 2
Offset: 1
The first such magic square is
2, 7, 6
9, 5, 1
4, 3, 8
From _M. F. Hasler_, Sep 23 2018: (Start)
The complete table reads:
[2, 7, 6, 9, 5, 1, 4, 3, 8]
[2, 9, 4, 7, 5, 3, 6, 1, 8]
[4, 3, 8, 9, 5, 1, 2, 7, 6]
[4, 9, 2, 3, 5, 7, 8, 1, 6]
[6, 1, 8, 7, 5, 3, 2, 9, 4]
[6, 7, 2, 1, 5, 9, 8, 3, 4]
[8, 1, 6, 3, 5, 7, 4, 9, 2]
[8, 3, 4, 1, 5, 9, 6, 7, 2] (End)
Cf.
A320871,
A320872,
A320873: inequivalent 3 X 3 magic squares of distinct integers, primes, consecutive primes.
-
squares = {}; a=5; Do[m = {{a + b, a - b - c, a + c}, {a - b + c, a, a + b - c}, {a - c, a + b + c, a - b}}; If[ Unequal @@ Flatten[m] && And @@ (1 <= #1 <= 9 & ) /@ Flatten[m], AppendTo[ squares, m]], {b, -(a - 1), a - 1}, {c, -(a - 1), a - 1}]; Sort[ squares, FromDigits[ Flatten[#1] ] < FromDigits[ Flatten[#2] ] & ] // Flatten
-
A217568=select(S->Set(S)==[1..9],concat(vector(9,a,vector(9,b,[a,b,15-a-b,20-2*a-b,5,2*a+b-10,a+b-5,10-b,10-a])))) \\ Could use that a = 2k, k = 1..4, and b is odd, within max(1,7-a)..min(9,13-a). - M. F. Hasler, Sep 23 2018
Showing 1-3 of 3 results.
Comments