# Method of marking diagonals

This algorithm is mentioned in Arabic sources from the 11th century. The square is first filled with the n2 numbers in a natural order. Starting at the top left with 1, the other numbers are entered consecutively from left to right and from top to bottom.

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

This square is now divided into subsquares of size 4, where the cells on the diagonals of the subsquares are marked.

Finally, all numbers z in the marked cells are replaced by their complementary numbers.

This results in the following magic square of order n=8.

 64 2 3 61 60 6 7 57 9 55 54 12 13 51 50 16 17 47 46 20 21 43 42 24 40 26 27 37 36 30 31 33 32 34 35 29 28 38 39 25 41 23 22 44 45 19 18 48 49 15 14 52 53 11 10 56 8 58 59 5 4 62 63 1

### Variant

This Algorithm can be modified in many ways. The simplest variant is not to replace the numbers in the marked fields with their complements, but to replace the numbers in the unmarked fields. The result is shown in the following square:

 1 63 62 4 5 59 58 8 56 10 11 53 52 14 15 49 48 18 19 45 44 22 23 41 25 39 38 28 29 35 34 32 33 31 30 36 37 27 26 40 24 42 43 21 20 46 47 17 16 50 51 13 12 54 55 9 57 7 6 60 61 3 2 64