Last updated October 4, 2026 · Report an error
A magic square is a grid of numbers where every row, column, and both diagonals sum to the same value (the magic constant). This tool can verify whether a grid you provide is a magic square, or generate a new one for any odd order using the classic Siamese method.
How it works
To verify, every row, column, and diagonal is summed and compared — if they all match, the grid is magic and that common sum is the magic constant. To generate an odd-order square, the Siamese method places 1 in the middle of the top row, then moves up-and-right for each subsequent number (dropping straight down when the up-right cell is already filled).
- Enter mode.
- Enter grid (rows separated by ";", numbers separated by ",").
- Enter size (n×n, odd only).
- Click Calculate to see your results.
Examples
A well-known 3x3 magic square
The grid [[2,7,6],[9,5,1],[4,3,8]] has every row, column, and diagonal summing to 15 — its magic constant.
Who should use it
- Recreational mathematics and magic square puzzles.
- Verifying homework or puzzle-book magic square answers.
Industry applications
- Mathematics education
- Recreational mathematics and puzzle design
Advantages
- Both verifies existing grids and generates new odd-order squares.
- Explains exactly which lines fail when a grid is not magic.
Limitations
- Generation is limited to odd orders (3, 5, 7) via the Siamese method — even-order magic squares require a different algorithm.
Common mistakes to avoid
- Assuming any grid with equal row sums is automatically a magic square — columns and both diagonals must also match for it to qualify.
Best practices
- When verifying a magic square by hand, check the diagonals as well as rows and columns — it's easy to overlook the diagonals since there are only two of them.
Tips
- If you need an even-order magic square, look into the LUX method or doubly-even construction techniques — the Siamese method used here does not apply to even orders.