Works on this device
Magic Square Checker
Type or paste a square of numbers and choose Check. The tool adds up every row, every column and both diagonals, and tells you whether the square is magic. Lines with a different sum are marked.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Check.
Your result
How it was worked out
How to use the checker
- Type the square with one row on each line, such as
2 7 6. Separate the numbers with spaces, commas or tabs. You can also choose one of the Example squares. - Choose Check.
- Read the result, the table of sums and the square with its sums. A sum that does not match is highlighted and underlined.
- To check against a sum of your own, such as 34 for a puzzle, type it under More options.
The rules
- A square of n rows and n columns has 2n + 2 lines: n rows, n columns and 2 diagonals. It is magic when every line has the same sum, the magic sum.
- The n rows hold every number of the square once, so the magic sum can only be the total of all numbers ÷ n. This is the sum the lines are checked against when you do not type one.
- A normal magic square holds each whole number from 1 to n² once. Its magic sum is n(n² + 1) ÷ 2: 15 for order 3, 34 for order 4 and 65 for order 5.
- A semi-magic square has rows and columns with the same sum, but a diagonal with another sum.
- Sums are worked out exactly, as fractions, so 0.1 + 0.2 is exactly 0.3.
Worked example
The square 2 7 6, 9 5 1, 4 3 8 holds the numbers 1 to 9. Their total is 45, and 45 ÷ 3 = 15. The rows are 2 + 7 + 6 = 15, 9 + 5 + 1 = 15 and 4 + 3 + 8 = 15. The columns are 15, 15 and 15. The diagonals are 2 + 5 + 8 = 15 and 6 + 5 + 4 = 15. All 8 lines match, so it is a normal magic square of order 3, and 3 × (9 + 1) ÷ 2 = 15.
Swap the 5 and the 1 in the middle row (9 1 5). The rows are still 15, but column 2 is 7 + 1 + 3 = 11, column 3 is 6 + 5 + 8 = 19, and both diagonals are 11 (2 + 1 + 8 and 6 + 1 + 4). The tool marks these 4 lines and says it is not a magic square.
Limits you should know
- Squares of 1 to 30 rows. Every row needs as many numbers as there are rows.
- All numbers on one line are read row by row when their count is a square number, such as 9 or 16.
- Broken diagonals are not checked, so the tool does not say whether a square is pandiagonal.
- The tool checks a square. It does not make or solve magic squares.