# De la Loubère

De la Loubère is often attributed to this simple method, but this is not the truth. Simon de la Loubère, who was envoy to the French king in Siam in 1687/88, tried to create a magic square on the return journey using the method of Bachet de Méziriac. A fellow traveler showed him a simpler method that he had learned in India and whose origin can be dated a few hundred years ago.

• Place the first number 1 in the center cell on the top row.
• Determine the next cell by going one row up and one column to the right.
• After exactly n steps, you get to an already occupied cell. Then return to the last valid position and make an intermediate step that takes you simply one row down.
• Whenever you are leave the square at one end, continue at the opposite side of the square.

Let's take a closer look at this algorithm for n=5. At the beginning, we place the number 1 in the center cell of the top row. For the second number, we have to move up one row and one column to the right and get a position that is outside the square. However, since we look at the rows and columns cyclically, we can subtract the order of the square from the row number obtained and again get a row number that lies within the square. 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. But this problem is also solved by looking at the columns cyclically.

The first group of 5 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 changed with an intermediate step, simply by going one row down from the last occupied cell.

According to this scheme, you can now continue until the entire square is filled with the numbers 1, 2, 3, … , n2.

 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9