Magic squares of odd order: Difference between revisions

J: simplify rank expression
(Added 11l)
(J: simplify rank expression)
Line 1,966:
Based on http://www.jsoftware.com/papers/eem/magicsq.htm
 
<lang J>ms=: i:@<.@-: |."0 1_1&|:^:2 >:@i.@,~</lang>
 
In other words, generate a square of counting integers, like this:
Line 1,995:
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_1 |:)^:2&i. ,~)</lang>
 
Example use:
6,962

edits