I am currently learning about magic squares and I want to construct a magic square. How do I construct a 6-by-6 or a 7-by-7 filled magic square, using the integers 0 to 35 or 0 to 48.
2026-03-25 20:40:14.1774471214
On
Constructing a magic square
1k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
I have thought about this problem some time ago. I don't know any theorems or proofs, but my method for an $n\times n$ square was the following:
- Make chips marked with the numbers from $0$ to $n-1$, $2n$ chips for each number. Of these $2n$ chips, make $n$ different from the other $n$ chips (for example, $n$ white chips and $n$ red chips).
- On an empty $n\times n$ board, you must put two chips in each square: a red one and a white one. If a square has a red $j$ and a white $k$, this represents that the number $nj+k$ is in this square (that is: $j$ and $k$ are the digits of the number in base $n$).
- In each row and column there must be the $n$ different numbers for each color, in a similar way to a Sudoku.
- You must also watch for the diagonals.
This way, I was able to make a 5x5 square and a 6x6 square. By the way, I think (but I don't have any proof either) that if $n$ is odd, the central square must contain the arithmetic mean of the row.
I know that this is far from a deterministic algorithm, but it is an idea to easen the work. Surely, there will be somebody that has a better answer.
Here is a method for producing $n\times n$ magic squares where $n$ is odd.
Choose $p$ and $q$ however you like. Start with an empty $n\times n$ grid. Put the number $q$ in the top center square.
Go up one row and move one square to the right. This takes you outside the $n\times n$ grid, above the top row, so return to the bottom square in the same column and write the number $p+q$. Go up one row and move one square to the right and write $2p+q$. Continue in this fashion; if you move up past the top row, return the the bottom square in the same column; if you move right past the last column, return to the leftmost square in the same row. If the next square is already filled, or if you reach the upper-right square in the array, move down one square and continue. At each step write a number that is $p$ more than the previous number.
For $n=5, p=1, q=1$ this produces
$$\begin{array}{|c|c|c|c|c|}\hline 17 & 24 & 1 & 8 & 15 \\\hline 23 & 5 & 7 & 14 & 16 \\\hline 4 & 6 & 13 & 20 & 22 \\\hline 10 & 12 & 19 & 21 & 3 \\\hline 11 & 18 & 25 & 2 & 9\\\hline \end{array}$$
If you don't care about the sum being correct on the diagonals, you can start anywhere, not just in the top center.