A magic square looks like a trick. Nine little boxes, nine ordinary numbers, and yet every row, every column and both diagonals add up to exactly the same total. The first time you see one finished, it feels like the numbers must have been arranged by luck. They were not. There is a method behind the arrangement, and once you know it, you can build one yourself in a couple of minutes with nothing more than a pencil and a scrap of paper. This guide walks through that method from the beginning: how to work out the target total, how to place the numbers in a three-by-three square, how to fill in a half-finished grid, and how to tackle bigger squares without guessing.
Start With the Magic Constant, Not the Grid
Every magic square has a target total, known as the magic constant, and working it out first changes the whole puzzle. Instead of staring at empty boxes wondering where to begin, you get a single number to aim for in every line. The formula is simple: for a square with n cells along each side, add up all the numbers from 1 to n squared, then divide by n. For the classic three-by-three square using the numbers 1 to 9, the numbers add up to 45, and 45 divided by 3 gives a magic constant of 15. That is the whole secret of the little square: every row, column and diagonal must total 15.
| Square size | Numbers used | Magic constant |
| 3 x 3 | 1 to 9 | 15 |
| 4 x 4 | 1 to 16 | 34 |
| 5 x 5 | 1 to 25 | 65 |
| 6 x 6 | 1 to 36 | 111 |
The 3×3 Centre Rule: Why 5 Always Sits in the Middle
Here is the first real shortcut. In a three-by-three square built from the digits 1 to 9, the centre cell is always 5. It is not a convention or a habit; it is forced by the arithmetic, and understanding why makes the rest of the puzzle far easier. Four lines pass through the centre cell: its row, its column, and the two diagonals. Those four lines must each total 15, so together they add up to 60. But those four lines cover every cell in the square once, plus the centre cell three extra times. All nine numbers add up to 45, so the centre cell must account for the difference between 60 and 45, which is 15, spread over its three extra appearances. Fifteen divided by three is 5, so the centre is 5, every single time.
Pairs That Add to Ten Do the Heavy Lifting
With the centre fixed at 5, the corners holding even numbers, and the edges holding odd numbers, the square almost builds itself. Put any even number in a corner, say 8 in the top left, and its partner 2 must sit in the opposite corner, the bottom right, because the diagonal through the centre has to total 15. Put 4 in the top right corner and 6 lands in the bottom left. Then the edges fill in from what is left: the top edge must complete the row 8 plus something plus 4 to make 15, so it is 3. The left edge completes 8 plus something plus 6, so it is 1. The bottom edge completes 6 plus something plus 2, so it is 7, and the right edge completes 4 plus something plus 2, so it is 9. Brushing up on a few mental maths tricks will make the adding-up stage far quicker, especially when you move on to bigger squares.
| 8 | 1 | 6 |
| 3 | 5 | 7 |
| 4 | 9 | 2 |
Worked Example: Filling a Half-Finished Grid
Most printed puzzles do not hand you a blank grid. They give you a few numbers already placed and ask you to find the rest, which is a slightly different skill. The trick is to work on the most complete line first, because each line you finish narrows down the lines around it. Take this half-finished square, which uses the same magic constant of 15:
| 8 | ||
| 5 | ||
| 2 |
The diagonal is already nearly complete: 8 plus 5 plus 2 equals 15, so that diagonal is done and it confirms the centre is correct. Next, look at the pairs that add to ten across the centre. The number opposite 8 is 2, which is already in place, so the remaining pairs to place are 1 with 9, 3 with 7, and 4 with 6. Start with the top row: 8 plus two unknown numbers must equal 15, so the two unknowns add to 7. From the numbers left, the pairs that add to 7 are 1 with 6 and 3 with 4. The third column must also total 15, and its bottom cell is 2, so its top two cells add to 13; the pairs left that add to 13 are 4 with 9 and 6 with 7.
Now look at the top right cell, which belongs to both of those lines. It must come from the top row pair, so it is 1, 6, 3 or 4, and it must also come from the third column pair, so it is 4, 9, 6 or 7. Only two numbers appear in both lists: 4 and 6. That means there are two mirror-image finishes, and either one is a correct solution, so pick one and follow it through. Choose 4 for the top right. The top row then needs 3 in the middle, since 8 plus 3 plus 4 equals 15. The third column now needs 9 in the middle, since 4 plus 9 plus 2 equals 15. The second row has 5 in the centre and 9 on the right, so its left cell is 1. The first column has 8 on top and 1 in the middle, so its bottom cell is 6. The bottom row has 6 and 2, so its middle cell is 7. Check everything: rows 8 plus 3 plus 4, 1 plus 5 plus 9, and 6 plus 7 plus 2 all equal 15, columns match too, and the second diagonal 4 plus 5 plus 6 equals 15. The finished square is:
| 8 | 3 | 4 |
| 1 | 5 | 9 |
| 6 | 7 | 2 |
Odd Squares Bigger Than 3×3: The Siamese Method
The three-by-three square is a warm-up. The real fun starts with five-by-five, where the same ideas scale up beautifully, and there is a classic technique for building any odd-sized square from scratch. It is called the Siamese method, and it needs no algebra at all, just three small rules. First, place the number 1 in the middle cell of the top row. Second, move one step up and one step to the right to place the next number, wrapping around to the opposite edge whenever you step off the grid. Third, if that target cell is already occupied, drop down one cell below the number you just placed instead. Repeat until every number is in.
Try it on a five-by-five grid, where the magic constant is 65. Place 1 in the top row, middle column. Move up and right for 2, which wraps to the bottom row, fourth column. Move up and right for 3, which lands in the fourth row, fifth column. Move up and right for 4, which lands in the third row, first column after wrapping sideways. Move up and right for 5, which lands in the second row, second column. Now the move for 6 would land on the cell holding 1, so the blocked-cell rule applies: drop one cell below 5 instead, and 6 goes in the third row, second column. From there the pattern resumes: 7 goes up and right into the second row, third column; 8 goes into the first row, fourth column; 9 goes into the fifth row, fifth column after wrapping. The first nine numbers are placed, and the rhythm is set: climb diagonally, wrap at the edges, and drop down whenever you hit an occupied cell. Keep going the same way until all 25 numbers are placed, and the finished square looks like this:

| 17 | 24 | 1 | 8 | 15 |
| 23 | 5 | 7 | 14 | 16 |
| 4 | 6 | 13 | 20 | 22 |
| 10 | 12 | 19 | 21 | 3 |
| 11 | 18 | 25 | 2 | 9 |
Even Squares: The 4×4 Diagonal Swap
Even-sized squares need a different approach, because the Siamese climb depends on having a single centre cell, which an even grid does not have. The four-by-four square has a neat method of its own, built on complementary pairs. Two numbers are complements if they add up to 17, which is one more than 16: so 1 pairs with 16, 2 with 15, 3 with 14, and so on down to 8 with 9. The method is to write the numbers 1 to 16 into the grid in order, reading left to right and top to bottom, and then to swap every number that sits on one of the two long diagonals for its complement.
Start with the grid filled in order. The top row reads 1, 2, 3, 4; the second row 5, 6, 7, 8; the third row 9, 10, 11, 12; and the bottom row 13, 14, 15, 16. Now look at the two diagonals. The falling diagonal holds 1, 6, 11 and 16, and the rising diagonal holds 4, 7, 10 and 13. Replace each of those eight numbers with its complement to 17: 1 becomes 16, 6 becomes 11, 11 becomes 6, 16 becomes 1, 4 becomes 13, 7 becomes 10, 10 becomes 7, and 13 becomes 4. Every other number stays exactly where it is. The result is a finished magic square with a constant of 34, and you can verify it in under a minute: the top row is 16 plus 2 plus 3 plus 13, the second row is 5 plus 11 plus 10 plus 8, and the diagonals are 16 plus 11 plus 6 plus 1 and 13 plus 10 plus 7 plus 4, all totalling 34.
| 16 | 2 | 3 | 13 |
| 5 | 11 | 10 | 8 |
| 9 | 7 | 6 | 12 |
| 4 | 14 | 15 | 1 |
How to Check Your Finished Square
Checking is part of solving, not an afterthought, and it takes less than a minute. Add up each row from left to right, then each column from top to bottom, then the two diagonals, and confirm that every total matches the magic constant you wrote at the top of the page. If one line is off, the mistake is in that line or in a line crossing it, which narrows the search enormously. Then check that every number from 1 to n squared appears exactly once by ticking each one off a list as you find it. A line can total correctly while still hiding a repeated number, so this second check catches errors the adding cannot. The elimination habits you build while solving a sudoku transfer neatly to magic squares, because both puzzles reward the same patience: find the most constrained spot, fill it, and let the consequences spread.
Try One Yourself
Here is a three-by-three square to finish on your own, using the same method from the worked example. The magic constant is 15, the centre is already filled in, and two corners are given:
| 2 | ||
| 5 | ||
| 8 |
Start with the diagonal, since 2 plus 5 plus 8 already equals 15, then work on the most complete line at each step, remembering that the missing corners must be even numbers. One finished square is 2, 9, 4 on top, 7, 5, 3 in the middle, and 6, 1, 8 along the bottom; its mirror image is equally correct. Check it yourself: every row, column and diagonal totals 15. Once that one feels easy, try building a five-by-five square with the Siamese method, and then a four-by-four with the diagonal swap. By the third square, the methods stop feeling like instructions and start feeling like something your hands know how to do.
That is really all there is to it. A magic square is not a mystery to be admired from a distance; it is a small piece of arithmetic with a satisfying rhythm, and the rhythm is learnable in a single sitting. Work out the constant, fix the centre, place your pairs, and let the most complete line guide you. Keep a pencil handy, keep your used numbers crossed off, and check the diagonals before you declare victory. The next time a magic square appears in a puzzle book or a newspaper, you will not wonder how anyone solves it. You will simply pick up the pencil and start. If you enjoy this kind of challenge, our round-up of the best number puzzle games has plenty to try next, from grid puzzles to arithmetic races.