Magic square generator and checker
A magic square fills a grid with numbers so that every row, column and diagonal adds up to the same sum. Here you can generate one from 3×3 to 15×15 or check your own.
Example: What would you like to do: Generate a square · Size n 3 · Variant 1 · Smallest number 1 · Step 1 → Result: 3 × 3: magic constant 15. Source: Wikipedia – Magisches Quadrat (magische Konstante, Siamesische Methode, Komplementmethode, Strachey-Methode). Updated: .
How it is calculated
The magic constant of a square of order n with the numbers 1 to n² is n · (n² + 1) / 2: 15 for 3×3, 34 for 4×4, 65 for 5×5.
How the square is built
For odd orders the Siamese method puts 1 above the centre and moves diagonally up and to the right, dropping one row down when a cell is taken. For orders divisible by 4 the numbers are written row by row and those on the diagonals of the 4×4 blocks are replaced by their complement n² + 1 − x. For order 4k + 2, Strachey’s method joins four sub-squares and swaps selected columns.
Variants and your own numbers
Rotations and reflections give up to 8 variants; the 3×3 square is unique apart from these symmetries. With a start number and step, 1, 2, 3 … can become 10, 12, 14 …, and the constant adapts: n · a + d · n · (n² − 1) / 2.
- There are 880 different squares of order 4 and already 275,305,224 of order 5 (not counting rotations and reflections).
- Checking: the calculator lists all row, column and diagonal sums and also recognises semi-magic squares.
Frequently asked questions
How do you calculate the magic number of a magic square?
n · (n² + 1) / 2. For 3×3 that is 3 · 10 / 2 = 15, for 4×4 it is 4 · 17 / 2 = 34.
How do you solve a 3×3 magic square?
Put 5 in the centre, even numbers in the corners and odd numbers on the edges: 8 1 6 / 3 5 7 / 4 9 2. All other solutions are rotations or reflections.
What is a semi-magic square?
A square in which all rows and columns have the same sum, but the diagonals do not.
Sources and legal basis
- Wikipedia – Magisches Quadrat (magische Konstante, Siamesische Methode, Komplementmethode, Strachey-Methode)
- Wikipedia – Magic square (construction methods, number of squares by order)
- Wolfram MathWorld – Magic Square
- OEIS A006052 – Number of magic squares of order n composed of the numbers from 1 to n^2, counted up to rotations and reflections
As of: · Editorial policy
Related tools
- Play sudoku online – daily puzzle and solverPlay sudoku online free: a new daily sudoku every day plus 4 levels, notes, mistake check and hints. The solver explains every step. Printable grid.
- Kakuro OnlinePlay Kakuro online for free: sum puzzles in three sizes and levels, each with exactly one solution, with a combination helper and hints. No sign-up.
- Calcudoku onlinePlay Calcudoku online for free: arithmetic Sudoku from 4 × 4 to 7 × 7, one solution each, with notes, hints, error checking and a puzzle series. No sign-up.
- Sequence CalculatorSequence calculator: enter numbers, find the rule (arithmetic, geometric, Fibonacci, quadratic), get the next terms, the nth term and the sum of n terms.
- Square numbers and cube numbersSquare numbers as a list up to 200 with differences, plus cube, triangular and other figurate numbers. Check whether a number belongs, with root and neighbours.
- Prime Number CalculatorPrime number calculator: list all primes up to 10 million, check whether a number is prime or find the nth prime – with twin primes, gaps and working.
- Online CalculatorCalculator online, free and instant: type or tap and see the answer as you go – order of operations, brackets, percent, square root, steps and a history list.
- Mean Absolute Deviation CalculatorMean absolute deviation calculator: find the MAD of a list around the mean or median, with the sum of absolute distances, steps and a worked example.
- Spur gear calculator: pitch, tip and root diameter from module and teethSpur gear calculator: reference, tip, root and base diameter, tooth depth, circular pitch and center distance from module and teeth – or the teeth from a.