Odd order (3, 5, 7, …)
Built with the Siamese method. M = 15, 65, 175, …
Magic constant n(n²+1)/2, magic square generator for any order, and a square checker.
Enter your values below to get started.
Set First number and Step to build a square from 5, 7, 9, … instead of 1, 2, 3, ….
In Check my square, a square that fails is drawn with the wrong lines in orange.
The Table tab of a generated square copies straight into a spreadsheet.
No 2 × 2 magic square with different numbers exists; every other order from 3 up has one.
A magic sum calculator finds the magic constant of an n × n magic square, the number that every row, column and main diagonal adds up to. For a square filled with 1 to n², the magic sum is M = n(n² + 1)/2: 15 for 3 × 3, 34 for 4 × 4 and 65 for 5 × 5. The calculator builds a magic square of any order from 3 to 30 and checks a square you type in.
A magic sum (magic constant) is the total that every row, every column and both main diagonals of a magic square add up to. In the 3 × 3 Lo Shu square below, all 8 lines add up to 15.
A normal magic square of order n uses each whole number from 1 to n² exactly once. Its magic sum depends only on n: 15 for n = 3, 34 for n = 4, 65 for n = 5, 111 for n = 6 and 260 for n = 8.
The Lo Shu is the oldest known magic square; Chinese legend tells of a turtle carrying its pattern out of the Luo River. Up to rotation and reflection, the Lo Shu is the only normal 3 × 3 magic square.
The magic sum calculator works in 3 modes: it computes M = n(n² + 1)/2, builds a magic square with the method that fits n, or adds every line of your square and compares the sums. Every generated square is checked line by line before it is shown.
Start with 1 in the middle of the top row, move up and right, and drop down one cell when the target is taken.
Write 1 … n² in order and replace k by n² + 1 − k on the diagonals of each 4 × 4 block.
John Horton Conway's LUX method expands an odd square of order n/2 into 2 × 2 blocks.
All 2n + 2 lines are added; the checker labels a square magic, semi-magic or not magic.
The magic sum formula for a normal n × n magic square is M = n(n² + 1)/2. It comes from sharing the total of 1 + 2 + … + n² equally between the n rows.
The first step is the formula for the sum of the first N whole numbers, N(N + 1)/2, credited to Carl Friedrich Gauss, with N = n².
For the numbers a, a + d, a + 2d, …, a + (n² − 1)d:
With a = 1 and d = 1 this reduces to n(n² + 1)/2.
Magic squares are grouped into 3 types by order (odd, doubly even, singly even) and into 4 types by their lines (semi-magic, magic, panmagic, associative). Each order type needs its own construction method.
Built with the Siamese method. M = 15, 65, 175, …
n divisible by 4. Built by the diagonal-swap pattern. M = 34, 260, 870, …
n = 4m + 2, the hardest case. Built by the LUX method. M = 111, 505, 1,379, …
Rows and columns add up to M, but at least 1 diagonal does not.
The broken diagonals add up to M too. The smallest panmagic squares are 4 × 4.
Every pair of cells symmetric about the center adds up to n² + 1. The Lo Shu and Dürer's square are associative.
To make an odd magic square by hand, put 1 in the middle of the top row, then place each next number one cell up and one cell right, wrapping around the edges, and move one cell down whenever the cell is full. Here is the 3 × 3 square.
The 4 best-known magic squares are the Lo Shu (sum 15), Albrecht Dürer's 1514 square (sum 34), the Sagrada Família square (sum 33) and Srinivasa Ramanujan's birthday square (sum 139). Each one shows a different trick.
Pick Magic constant, Generate a square or Check my square, fill in the order n (or paste your square) and press Calculate. The result shows the magic sum, the square itself, the step-by-step working and a table you can copy.
Each mode shows only the inputs it needs.
Any whole number for the constant; 3 to 30 for a generated square.
First number and step build squares from sequences such as 10, 20, 30, ….
Paste one row per line; wrong lines turn orange in the Square chart.
Magic sums are used in recreational mathematics, puzzle design, art and the teaching of arithmetic. 5 examples:
7 magic square tasks and their answers. Press Try to load any row into the calculator.
| Task | Detail | Answer | Calculator |
|---|---|---|---|
| Magic constant | n = 3 | M = 15 | |
| Magic constant | n = 4 | M = 34 | |
| Magic constant | n = 10 | M = 505 | |
| Generate | 5 × 5, Siamese | M = 65 | |
| Generate | 6 × 6, LUX | M = 111 | |
| Check | Dürer's 1514 square | Normal magic square, M = 34 | |
| Check | Sagrada Família square | Magic square with repeats, M = 33 |
Solve each one, then reveal the answer or check it in the calculator.
What is the magic sum of a normal 5 × 5 magic square?
What is the magic sum of a normal 8 × 8 magic square?
A 3 × 3 magic square uses 5, 7, 9, …, 21. What is its magic sum?
Is 2 7 6 / 9 5 1 / 4 3 8 a magic square?
What is the magic sum of Ramanujan's square 22 12 18 87 / 88 17 9 25 / 10 24 89 16 / 19 86 23 11?
Classify the square 1 2 3 / 2 3 1 / 3 1 2.
Discover 67 free sum calculators across different categories. Find the right calculator for your needs.
Try a different name or choose another category.
A magic sum calculator is an online tool that returns the magic constant M = n(n² + 1)/2 of an n × n magic square, builds a magic square of a chosen order and checks whether a square you enter is magic.
The magic sum of a normal 3 × 3 magic square is 15: 3(9 + 1)/2 = 15. The numbers 1 to 9 add up to 45, shared equally between 3 rows.
The magic constant of a normal 4 × 4 magic square is 34, since 4(16 + 1)/2 = 34. Dürer's 1514 square is a famous example.
No, a 2 × 2 square with different numbers cannot have equal rows, columns and diagonals. Every order n ≥ 3 has magic squares.
Use the Siamese method: put 1 in the middle of the top row, place each next number one cell up and one cell right (wrapping around the edges), and move one cell down when the cell is taken.
There are 880 normal 4 × 4 magic squares, not counting rotations and reflections, as Bernard Frénicle de Bessy found in 1693.
In a magic square, rows, columns and both main diagonals share one sum. In a semi-magic square, only the rows and columns do.
Yes, any arithmetic sequence a, a + d, … works with the same layout. Its magic sum is M = n·a + d·n(n² − 1)/2, so 5, 7, …, 21 in a 3 × 3 square gives 39.
A panmagic square is a magic square whose broken diagonals (diagonals that wrap around the edges) add up to the magic sum as well. The smallest panmagic squares have order 4.
The magic sum of a normal n × n magic square is M = n(n² + 1)/2, and the magic sum calculator returns it for any n, builds a square for orders 3 to 30 and checks squares you type in. Use the Siamese method for odd n, the diagonal swap for multiples of 4 and the LUX method for 6, 10, 14 and the other singly even orders.
Not sure which method builds your square? Answer up to 2 questions below.