To write a magic square is not so hard.
The group of 2K+1 (odd ) except 6k+3 (9,15,21,27,...) is easy to make a panmagic square:
For example, order 5
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00
Use the Move step Right 1-Down 3 (from 1 to 5)
01 00 00 00 00
00 00 03 00 00
00 00 00 00 05
00 02 00 00 00
00 00 00 04 00
Use the Turn step Right 3- Down 1 (from 1 to 6 to 11 to 16 to 21)
01 09 00 00 00 6-10 use Move step 1-3
00 00 03 06 00
08 00 00 00 05
00 02 10 00 00
00 00 00 04 07
01 09 00 00 00 11 use Turn step 3-1 from 6
00 00 03 06 00
08 11 00 00 05
00 02 10 00 00
00 00 00 04 07
01 09 12 00 00 11-15 use Move step 1-3
00 00 03 06 14
08 11 00 00 05
00 02 10 13 00
15 00 00 04 07
01 09 12 20 00 16-20 use Move step 1-3
17 00 03 06 14
08 11 19 00 05
00 02 10 13 16
15 18 00 04 07
01 09 12 20 23 21-25 use Move step 1-3
17 25 03 06 14
08 11 19 22 05
24 02 10 13 16
15 18 21 04 07
It is a panmagic square of order 5 .
Order 7,11,13,17,19,23,25,29,31,...can use the same method to make panmagic squares.
The group of 2K+1 (odd ) except 6k+3 (9,15,21,27,...) is easy to make a panmagic square:
For example, order 5
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00
00 00 00 00 00
Use the Move step Right 1-Down 3 (from 1 to 5)
01 00 00 00 00
00 00 03 00 00
00 00 00 00 05
00 02 00 00 00
00 00 00 04 00
Use the Turn step Right 3- Down 1 (from 1 to 6 to 11 to 16 to 21)
01 09 00 00 00 6-10 use Move step 1-3
00 00 03 06 00
08 00 00 00 05
00 02 10 00 00
00 00 00 04 07
01 09 00 00 00 11 use Turn step 3-1 from 6
00 00 03 06 00
08 11 00 00 05
00 02 10 00 00
00 00 00 04 07
01 09 12 00 00 11-15 use Move step 1-3
00 00 03 06 14
08 11 00 00 05
00 02 10 13 00
15 00 00 04 07
01 09 12 20 00 16-20 use Move step 1-3
17 00 03 06 14
08 11 19 00 05
00 02 10 13 16
15 18 00 04 07
01 09 12 20 23 21-25 use Move step 1-3
17 25 03 06 14
08 11 19 22 05
24 02 10 13 16
15 18 21 04 07
It is a panmagic square of order 5 .
Order 7,11,13,17,19,23,25,29,31,...can use the same method to make panmagic squares.