Magic square puzzle
Fill the empty cells so that every row, column and both diagonals add up to the magic constant. Each puzzle has exactly one answer, and the lines are checked as you type.
Lines correct
of 8 lines add up to the constant
How this is calculated
A normal magic square uses the numbers 1 to n² once each, and every line equals
M = n(n² + 1) / 2
That is 15 for 3 × 3 and 34 for 4 × 4. A grid has 2n + 2 lines: n rows, n columns and 2 diagonals. The figure above counts the lines that are completely filled and add up to M. A line with a blank does not count yet.
Each puzzle starts from a magic square, then clears some cells. The cleared cells are chosen so that their rows and columns let you work out every missing number, which is why each puzzle has exactly one answer. The page checks this with the same solver as the magic square solver.
Rules and limits
- Blanks: 1 to 7. A puzzle needs at least one blank, and with more than 7 the answer may not be unique.
- You may type a repeated number. The cell is marked, the page says which numbers repeat, and the puzzle cannot count as solved while any number repeats.
- Only whole numbers from 1 to n² are accepted. Anything else shows an error and no result.
- The puzzle number is shown so that you can come back to the same puzzle. There are no timers, scores or accounts, and nothing is stored.
Three solving tips
- Use the constant. Any line with one blank gives the missing number: M minus the sum of the others.
- Look for lines with a single blank first, then repeat; each filled cell can unlock another line.
- In a 3 × 3 square the centre is always 5. The 3 × 3 magic square guide shows why. The 4 × 4 guide covers the larger grid.
Playing with the keyboard
Press Tab to move from cell to cell and type a number. Press Enter in any field to check the grid. The Hint button fills in one correct cell and locks it. It is placed on the first cell, reading left to right and top to bottom, that does not match the answer.
Sources
- Weisstein, Eric W. “Magic Square.” MathWorld, A Wolfram Resource. mathworld.wolfram.com/MagicSquare.html (constant formula).
Want paper puzzles?
The magic square worksheets page makes printable sheets with an answer page. To build a full square from scratch, use the magic square generator.