A320871 List of all inequivalent 3 X 3 magic squares made of distinct positive integers, sorted by increasing sum. For each equivalence class modulo symmetries of the square, the lexicographically smallest representative is shown.
2, 7, 6, 9, 5, 1, 4, 3, 8, 2, 9, 7, 11, 6, 1, 5, 3, 10, 3, 7, 8, 11, 6, 1, 4, 5, 9, 3, 8, 7, 10, 6, 2, 5, 4, 9, 2, 11, 8, 13, 7, 1, 6, 3, 12, 3, 10, 8, 12, 7, 2, 6, 4, 11, 4, 8, 9, 12, 7, 2, 5, 6, 10, 4, 9, 8, 11, 7, 3, 6, 5, 10, 2, 13, 9, 15, 8, 1, 7, 3, 14, 3, 11, 10, 15, 8, 1, 6, 5, 13
Offset: 1
Examples
The first five inequivalent magic squares (with magic sums 15, 18, 18, 18, 21) are [2 7 6] [ 2 9 7] [ 3 7 8] [ 3 8 7] [ 2 11 8] [9 5 1] [11 6 1] [11 6 1] [10 6 2] [13 7 1] [4 3 8] [ 5 3 10] [ 4 5 9] [ 5 4 9] [ 6 3 12] They are listed as rows of the 9 elements of each square, so the first row is: [2, 7, 6; 9, 5, 1; 4, 3, 8], the second row is: [2, 9, 7; 11, 6, 1; 5, 3, 10], and so on.
Crossrefs
Programs
-
PARI
A320871_row(N=10,show_all=1,c=3)={for(c=c,oo, forstep(d=c-1,2,-1, for(b=max(2*d+1-c,1), d-1, d!=2*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_all&&print(S))&& !N--&& return(S))))} \\ The third (optional) argument allows starting the list with the first square(s) having the central element >= c, i.e., magic sum >= 3c.
Comments