A very simple method to create magic squares of odd order is known as Moschopoulos. But nowadays we know from a writing by an unknown author from the 12th century that the algorithm known as Moschopoulos actually comes from Ibn al-Haytham (approx. 965 – 1041).
This method creates magic squares for all odd orders n and was the most common method in the years after its creation due to its simplicity. It can be described with the following steps.
At the beginning we place the number 1 in the cell directly below the center of the square. For the second number we have to move down one row and one column to the right. Likewise for the third number and get a position that is outside the square. But since we look at the rows and columns cyclically, we can add the order of the square from the row number and again get a row number that lies within the square. In other words, we walk around the square in the same column and continue at the opposite end.
With the fourth step there is again a small problem, as we have moved out of the square to the right.
The first group of five numbers is now correctly positioned. The next number, however, already creates a new problem, since the number 6 would lead to the cell already occupied by the number 1. At this point, the given sequence of steps must be interrupted with a special intermediate step, in which we simply move down two rows from the last occupied cell.
You can continue with these steps until the entire square is filled with the numbers 1, 2, 3, … , n2.