Magic squares of odd order: Difference between revisions

m
J: oops, diagonals matter
(J: simplify rank expression)
m (J: oops, diagonals matter)
Line 1,993:
515201</lang>
 
Note also that an important feature of magic squares is that their diagonals sum the same way:
Or, based on suggestion by Marios Mamzeris on the talk page (which is similar but oriented different -- both rows and columns shifted somewhat):
 
<pre> 9+21+13+5+17
<lang J>msmm=: 1 + ((|."_1 |:)^:2&i. ,~)</lang>
65
 
3+8+13+18+23
Example use:
65</pre>
 
<lang J> msmm 5
1 7 13 19 25
12 18 24 5 6
23 4 10 11 17
9 15 16 22 3
20 21 2 8 14
+/msmm 5
65 65 65 65 65</lang>
 
=={{header|Java}}==
6,962

edits