Generate a magic square where every row, column and diagonal sums to the same magic constant, for odd orders and multiples of 4.
Result
How to use this tool
Enter an odd order (3, 5, 7, 9) or a multiple of 4 (4, 8).
Read the generated grid in the results area.
Confirm every row, column and diagonal sums to the magic constant.
Copy the grid for puzzles, worksheets or recreational maths.
Formula & worked example
The classic 3 × 3 square (8 1 6 / 3 5 7 / 4 9 2) has every row, column and diagonal summing to 15.
Limitations — read this before you rely on it
Covers odd orders and doubly-even orders from 3 to 9. Singly-even orders (6, 10, …) are not generated; the tool says so rather than giving a wrong square.
Frequently asked questions
A grid of distinct numbers where every row, column and both main diagonals add to the same magic constant.
For order n using 1 to n², it is n(n² + 1) / 2: 15 for 3 × 3, 34 for 4 × 4, 65 for 5 × 5.
The classic construction for odd orders: place 1 in the top-middle, then move up-right, dropping down when the next cell is taken.
Singly-even orders need a more involved construction (the Strachey method); this tool covers odd orders and multiples of 4.
No. Rotations and reflections of one square give others with the same constant.
