Math Playground
Back to Puzzles

Puzzles › Magic Square

Magic squares

Place 1 through 9 in a 3×3 grid so every row, column and diagonal adds to the same number.

3×3 Magic Square

Fill with 1–9 (each once) so every row, column and diagonal sums to 15.

·
·
·
·
·
·
↘ diagonal: 0
↙ diagonal: 0
Show one solution
2
7
6
9
5
1
4
3
8

Why 15?

The numbers 1 + 2 + 3 + … + 9 add up to 45. There are 3 rows that must each sum to the same value, and they cover every cell once. So each row sums to 45 ÷ 3 = 15.

Where the 5 lives

The center cell appears in 4 of the 8 lines (row, column, two diagonals). For the math to balance out, the center has to be 5 — the middle of 1–9.

A famous arrangement

The Lo Shu square (an ancient Chinese arrangement) puts 5 in the middle, evens in the corners, odds on the sides. Once you place 5 and the corners, the rest follows.

Bigger magic squares

A 4×4 magic square uses 1–16 and each line sums to 34. A 5×5 uses 1–25 and sums to 65. The general formula for an n×n magic square built from 1 to n²: each line sums to n(n² + 1) / 2.