Magic Square

Fill in the empty squares so that every row, column and diagonal adds up to the same number. On a 3×3 board, that number is 15.

Choose your settings and press “Start”

Mode

Board size
Difficulty

Report a bug

Only the site operators can read your report. It will not appear in public comments.

Do not include your name, school, address, contact details, or links. The game version and browser type are attached automatically. Privacy

ver 1.0.0 · Updated

Release notes
  1. · ver 1.0.0Added the version label and release notes.
  2. Added the English version.
  3. First published.

How to play the magic square puzzle

A magic square is a grid of numbers in which every row, every column and both main diagonals add up to exactly the same total. In this puzzle, some of the numbers are already on the board and your job is to fill in the rest. There is no guessing involved and no special math needed – only addition, subtraction and a bit of careful thinking – which makes it a relaxing brain teaser and good arithmetic practice at the same time.

Magic square rules

A 3×3 magic square with the rows 4 9 2, 3 5 7 and 8 1 6. All eight sum chips around the board – three rows, three columns and two diagonals – show 15 in green.
On a 3×3 board you use 1 to 9 once each, and all eight lines must add up to 15.

There are only two rules. First, use every number from 1 up to the number of squares exactly once: 1–9 on a 3×3 board, 1–16 on a 4×4 board and 1–25 on a 5×5 board. Second, every row, every column and both corner-to-corner diagonals must have the same sum. That shared total is called the magic sum (or magic constant). It is 15 for 3×3, 34 for 4×4 and 65 for 5×5.

You can work the magic sum out yourself. Add up all the numbers on the board and split the total evenly between the rows. On a 3×3 board, 1 + 2 + … + 9 = 45, and three rows share it, so each row must be 45 ÷ 3 = 15. The general formula for an n×n square is n(n² + 1) ÷ 2.

What doesn’t count as a magic square

Three 3×3 boards compared. The left one is a real magic square with all eight lines at 15. The middle one has every row and column at 15, but its diagonals add up to 24 and 12, so it fails. The right one uses 5 nine times, so it fails even though every sum is 15.
Both diagonals must match, and no number may appear twice.

The most common near miss is a grid where the rows and columns all match but the diagonals don’t. That is only a “semi-magic” square – the two diagonals have to line up as well. The other trap is repeating a number. Filling every square with 5 makes all the sums equal, but it breaks the first rule, so it doesn’t count.

Using the game screen

The game screen. On a 4×4 board an empty square is selected with a blue outline, and the number buttons 1 to 16 sit below the board. Sum chips on the right, along the bottom and in the two right-hand corners show the current total of each line, and lines that reach 34 turn green. Used numbers are faded and numbers that were already on the board have a dashed outline.
(1) Select a square, (2) press a number. (3) The chips around the board show each line’s current sum.

Press an empty square to select it, then press one of the number buttons below the board. The chips on the right show the total of each row, the chips along the bottom show each column, and the two corner chips show the diagonals (the little arrow tells you which one). A line that reaches the magic sum turns green. A line that is full but wrong – or that has already gone over the target – turns red. Number buttons you have already used are faded, so you can see at a glance what is left. If you press a faded number, it moves from its old square to the one you selected.

You can also play with a keyboard: arrow keys move between squares, number keys fill them in, and Backspace erases. On 4×4 and 5×5 boards, type two-digit numbers in a row – 1 then 2 gives 12. Because a 1 might be the start of 10–16, the game waits briefly and shows a note under the board. Press Enter to lock in a single 1 straight away, or simply wait a moment.

“Hint” first outlines a square that can be worked out from what is already on the board. Press it again for the reasoning (a subtraction or a list of possible pairs), and a third time to fill in the number. “Check” marks any wrong numbers in red. Both are counted as help in your records.

Three ways to play

ModeWhat you do
PuzzlesChoose a board size and difficulty and solve one puzzle after another. The game keeps track of how many you have solved, how many without help, your personal best time and your average.
Daily puzzleThree fixed puzzles for each date – one 3×3, one 4×4 and one 5×5 – with a combined time. Everyone gets the same puzzles on the same day, so you can race friends or family.
Blank boardStart with nothing and build your own magic square. Any arrangement is accepted as long as every sum matches. The game remembers which squares you have found: 8 orientations for 3×3 and 880 distinct squares for 4×4.

Board sizes and difficulty

Example magic squares in three sizes: 3×3 uses 1 to 9 with a sum of 15, 4×4 uses 1 to 16 with a sum of 34, and 5×5 uses 1 to 25 with a sum of 65.
Bigger boards mean more numbers and more lines to balance.

Difficulty depends on the board size and on how many numbers you are given at the start. Fewer givens means more squares to reason out on your own. Every puzzle has exactly one answer, and each one can be solved square by square with a clear reason for every step – you never have to guess and backtrack.

SizeNumbers · magic sumNumbers given
3×31–9 · 15Easy 4 · Normal 3 · Hard 2
4×41–16 · 34Easy 10 · Normal 8 · Hard 6
5×51–25 · 65Easy 17 · Normal 14 · Hard 12

On 4×4 and 5×5, Easy puzzles fall to subtraction alone: keep finding lines with a single gap. Normal and Hard puzzles will get stuck at some point unless you use the pair-listing and placement tricks described below. If you are new to magic squares, start with 3×3 and work your way up.

How to solve a magic square: tips and strategy

1. Look for a line with one empty square

A 3×3 board whose top row holds 4 and 9 with the right-hand square empty. 15 − (4 + 9) = 2, so the empty square must be 2.
Read the sum chip and subtract – that’s the whole move.

This is the move you will use most. If a row, column or diagonal has only one empty square left, the missing number is simply the magic sum minus the current total. The chip beside the line already shows that total, so it takes one subtraction. Filling one gap often leaves another line with a single gap, and the solution starts to snowball.

2. The center of a 3×3 magic square is always 5

A 3×3 magic square with the four lines through the center highlighted: the middle row, the middle column and both diagonals. Together they add up to 15 × 4 = 60. They cover every square once, except the center, which is covered four times, so 45 + center × 3 = 60 and the center is 5.
Add up the four lines through the middle and the center number falls out.

Here is a neat piece of reasoning. Four lines pass through the center of a 3×3 square – the middle row, the middle column and both diagonals – and together they add up to 15 × 4 = 60. Between them they touch every square exactly once, except the center, which they touch four times. The numbers 1 to 9 add up to 45, so 45 + 3 × center = 60, which means the center is 5. It follows that any two numbers facing each other across the center add up to 10, and in every 3×3 magic square the corners are even numbers. With those three facts, most 3×3 puzzles solve themselves.

3. Compare the possible pairs in crossing lines

A 4×4 board. A column has two empty squares that must add up to 21, and the only unused pair is 5 + 16. A diagonal has two empty squares that must add up to 6, and the only unused pair is 1 + 5. The dashed square where they cross can only be 5.
When two lines cross, their candidates overlap – often in just one number.

When a line has two empty squares, you know what they must add up to: the magic sum minus the current total. Now list the pairs of unused numbers that make that amount. Surprisingly often there are only one or two. If a square sits where two such lines cross, it can only hold a number that appears in both lists. When only one number survives, you have found it.

4. Ask where a number can go

If working square by square stalls, flip the question around and think about a number instead. Pick an unused number – say 25 on a 5×5 board – and rule out every empty square where it would push a line over the magic sum. If only one spot remains, that is where 25 belongs. The biggest and smallest numbers are the easiest to place this way, because they fit in the fewest places.

5. Think in high and low pairs

On a 5×5 board, two empty squares that need to total 45 can only be filled with big numbers: 20 + 25, 21 + 24 or 22 + 23. A line that needs a small total can only take small numbers. Just noticing whether a remaining sum is large or small cuts down the candidates dramatically, even before you write out any pairs.

6. Use the colors to find mistakes

If the board is full but not solved, look at the red chips. A square where two red lines cross is the most likely culprit. When you are unsure, “Check” will highlight any wrong numbers so you can fix them and carry on.

Magic square FAQ

Does each puzzle have only one solution?

Yes, in Puzzles and Daily puzzle mode every puzzle has exactly one answer. The starting numbers are chosen so that even the rotation and mirror image of the square are fixed. In Blank board mode there is no single answer – any arrangement where all the sums match is correct.

How many 3×3 magic squares are there?

Only one, if you treat rotations and reflections as the same square. Counted separately, there are eight versions. Blank board mode keeps a tally, so you can try to find all eight.

How many 4×4 and 5×5 magic squares exist?

Treating rotations and reflections as one, there are 880 magic squares of size 4×4 – a count first worked out in the 17th century – and 275,305,224 of size 5×5, a figure computed in 1973. A 2×2 magic square is impossible.

Why doesn’t a 1 appear right away when I type it on a 4×4 board?

On 4×4 and 5×5 boards a 1 (or a 2 on 5×5) could be the first digit of a two-digit number, so the game waits briefly for a second key. Press Enter after the 1 to place it immediately. The on-screen number buttons never wait.

Is there a magic square solver or answer key?

Every puzzle comes with its own step-by-step helper. “Hint” shows the next square you can deduce and explains why, and “Show answer” fills in the complete solution. In Blank board mode, “Check” tells you whether the numbers you have placed can still be completed into a magic square.

When does the daily puzzle change?

A new set of three appears when the date changes on your device. You can replay the same day’s puzzles as often as you like, but only your first completion counts as that day’s record.

Can I stop and continue later?

Yes. Open the page again on the same device and browser and press “Continue” to pick up where you left off. The game starts with sound off; press “Sound: off” below the board to turn on the sound effects.

A short history of the magic square

Magic squares are among the oldest number puzzles in the world. An old Chinese legend tells of a turtle that climbed out of the river with a pattern of dots on its shell, arranged as the 3×3 magic square. That pattern is known as the Lo Shu (洛書), although how much of the story is true nobody really knows. In Europe, the artist Albrecht Dürer placed a 4×4 magic square in his 1514 engraving Melencolia I, and slipped the year of the work into the two middle squares of the bottom row: 15 and 14. A magic square is nothing more than numbers in a grid, yet questions like “why is the center always 5?” and “how many are there?” have kept mathematicians and puzzle fans busy for centuries.