Magic squares of odd order: Difference between revisions
m
J: interesting alternate approach
Thundergnat (talk | contribs) (→{{header|Raku}}: Fix up some internal links) |
m (J: interesting alternate approach) |
||
Line 1,960:
~.+/ms 101
515201</lang>
Or, based on suggestion by Marios Mamzeris on the talk page (which is similar but oriented different -- both rows and columns shifted somewhat):
<lang J>msmm=: 1 + ((|."0 1 |:)^:2&i. ,~)</lang>
Example use:
<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}}==
|