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.

12345678
910111213141516
1718192021222324
2526272829303132
3334353637383940
4142434445464748
4950515253545556
5758596061626364

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

Method of Diagonals

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

Complement

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

642361606757
955541213515016
1747462021434224
4026273736303133
3234352928383925
4123224445191848
4915145253111056
858595462631

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:

163624559588
5610115352141549
4818194544222341
2539382829353432
3331303637272640
2442432120464717
165051131254559
577660613264