Magic Square — free online math game
3-15 min
Magic Square

Magic Square

Math

Place every number from 1 up once so each row, column and both diagonals add up to the same total, from a 3×3 to a 5×5.

Score 0 Best 0

Home / Math / Magic Square

Magic Square is a free online math puzzle built on one of the oldest number puzzles there is. An n×n grid holds every number from 1 to n² exactly once, and every row, every column and both long diagonals add up to the same magic total: 15 on a 3×3, 34 on a 4×4, 65 on a 5×5. Some numbers are given, and you place the rest. Tap an empty square and then a number from the tray (below the board, or beside it on a wide screen), or pick the number first and tap the square; on a keyboard, type it. A running total beside every row, under every column and at the ends of both diagonals turns green when the line is right and red as soon as the numbers left can no longer bring it to the target, so you can check your arithmetic as you go. Every square is generated fresh from a real magic square, has exactly one answer, and is proved solvable by reasoning alone before you see it. Eight levels grow from the ancient 3×3 Lo Shu to a 5×5 with as few as nine numbers given, and the hardest ask you to follow a "what if" until a line refuses to add up. No download, no account.

How to play Magic Square

  1. The board is an n×n grid. When it is finished it holds every number from 1 to n² exactly once — 1 to 9 on a 3×3, 1 to 16 on a 4×4, 1 to 25 on a 5×5.
  2. Every row, every column and both long diagonals must add up to the magic total shown above the board: 15, 34 or 65. It is always n × (n² + 1) ÷ 2.
  3. Gold squares are given and cannot change. Fill the dark ones.
  4. Tap an empty square, then tap a number in the tray (below the board, or beside it on a wide screen) to put it there. You can also tap the number first and then the square.
  5. A number can only be on the board once, so placing one that is already down moves it. Tapping a square's own number in the tray again empties the square, and ⌫ empties the selected square.
  6. The small totals beside each row, under each column and at the ends of the two diagonals show what each line adds up to so far. Green means the line is full and right; red means no choice of the numbers still unused can bring it to the target.
  7. On a keyboard, arrow keys move between squares, digits type a number, Backspace clears, and Enter finishes a number early. On a 4×4 a "1" waits a moment in case a second digit follows, and on a 5×5 so does a "2".
  8. Turn on Mistakes to mark any number that differs from the answer, or use the ? button, three times per board, to fill one square. A hint corrects a wrong number before it fills an empty one.
  9. The puzzle is solved when every line adds up. Undo steps back one move, Clear wipes your numbers, and New Puzzle builds a different square on the same level.

Tips

  • Start with any line that has one empty square: that square is the magic total minus the rest of the line.
  • With two empty squares in a line, write down what they must add up to and list the pairs of unused numbers that make it. Often only one pair fits the other lines through those squares.
  • The middle of a 3×3 is always 5, and the corners are always even. Every 3×3 magic square is the ancient Lo Shu turned or flipped.
  • On a 4×4, the four corners always add up to 34 too, and so do the four middle squares. Those are handy extra lines to check against.
  • Watch the unused numbers, not just the lines. If a big number like 25 can only fit in one square because every other line would overflow, it goes there.
  • A red total is an early warning: the line can no longer be finished with what is left, even before it is full. Undo back to the last number you were sure of.
  • On the hardest levels, pick a square with only two or three possible numbers and ask what happens if you put the first one in. If a line then cannot add up, the number goes elsewhere.

FAQ

Is Magic Square free to play?

Yes. It runs in the browser with no download, no sign-up and nothing to buy. All eight levels are included and unlock as you solve them.

What is a magic square?

A square grid holding the numbers 1 to n² once each, arranged so that every row, every column and both main diagonals have the same sum, called the magic constant. For a 3×3 that sum is 15, for a 4×4 it is 34 and for a 5×5 it is 65.

How do you work out the magic constant?

Add up all the numbers and divide by the number of rows. The numbers 1 to n² add up to n²(n² + 1) ÷ 2, and there are n rows, so each row gets n(n² + 1) ÷ 2. The game shows the total above every board so you never have to work it out mid-puzzle.

Does every puzzle have exactly one answer?

Yes, and it is checked rather than assumed. Each board starts from a real magic square, and numbers are taken away only while a program that makes nothing but forced moves can still finish it. A board it can finish has one answer, and the tests confirm that with an exhaustive search as well.

Will I ever have to guess?

No. Every board can be finished by reasoning alone. The first level of each size needs only lines with one square left, the second needs you to work out which pairs or triples of unused numbers can finish a line, and the 4×4 and 5×5 finales need at least one "what if" followed until a line cannot add up.

How many 3×3 magic squares are there?

Only one, up to turning and flipping: the Lo Shu square, recorded in China around two thousand years ago, with 5 in the middle. Its eight rotations and reflections are the only ways to arrange 1 to 9 so every line adds to 15. For a 4×4 there are 7,040 arrangements, and the game's own tests count every one of them.

How many levels are there?

Eight: two 3×3s, three 4×4s and three 5×5s. Within each size the kind of reasoning gets harder, not just the number of empty squares. New Puzzle gives a fresh board on any level you have reached.

Is it good for practising mental math?

Yes. Every move is an addition or subtraction against a fixed target, and the harder levels have you comparing sums of pairs and triples, so it works as arithmetic practice for older children and adults alike, with the running totals there to check each step.

Does it work on a phone?

Yes. Tapping a square and then a number is the whole input, and on a phone held upright the frame grows taller so even the 5×5 board and its 25-number tray keep targets large enough to tap.