Jump to content

Magic squares of odd order: Difference between revisions

add RPL
(Added XPL0 example.)
(add RPL)
Line 4,535:
 
the magic number is : 369
</pre>
 
=={{header|RPL}}==
{{trans|IS-BASIC}}
≪ → n
≪ n DUP 2 →LIST 0 CON
1 n '''FOR''' j
1 n '''FOR''' k
j k 2 →LIST
j 2 * k - n + 1 - n MOD n *
j 2 * k + 2 - n MOD 1 +
+ PUT
'''NEXT NEXT'''
n DUP SQ 1 + * 2 /
≫ ≫ '<span style="color:blue">ODDMAGIC</span>' STO
 
5 <span style="color:blue">ODDMAGIC</span>
{{out}}
<pre>
2: [[2 23 19 15 6 ]
[14 10 1 22 18]
[21 17 13 9 5]
[8 4 25 16 12]
[20 11 7 3 24]]
1: 65
</pre>
 
1,151

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.