What is a magic square?

A magic square is an N×N grid of distinct numbers, usually from 1 to N², where every row, column, and main diagonal shares the same sum, called the magic constant.

The most famous example is the Lo Shu 3×3 square, linked to ancient Chinese tradition. It uses the numbers 1 to 9 and all rows, columns, and diagonals sum to 15.

2
9
4
7
5
3
6
1
8
Lo Shu 3×3 — magic constant 15

In Europe, the 4×4 square in Albrecht Dürer’s engraving “Melancholia I” is among the most famous historic examples, using numbers 1 to 16 with constant 34.

Magic squares remain one of the classic logic-number puzzles because they blend pattern, counting, and reasoning.

How to compute the magic constant

For a grid from 1 to N², use the standard formula:

Magic constant = N × (N² + 1) / 2
3×3 = 15
4×4 = 34
5×5 = 65
6×6 = 111

Because the total of 1 to N² is N²(N²+1)/2, dividing by N lines gives the same target for each row or column.

This formula is the first checkpoint before placing any number.

Four ways to build a magic square

Siamese method (odd-sized squares)

For sizes 3×3, 5×5, 7×7, and other odd sizes, place 1 in the middle of the top row, then move up-right for each next number, wrapping around borders. When a filled cell is encountered, move down one instead. This generates a valid square consistently.

LUX method (doubly even squares)

For sizes such as 4×4 and 8×8, the LUX approach builds from patterned sub-tiles and then applies a number fill strategy. It is more mechanical but systematic and reliable.

Rotation and reflection

Once one valid square is built, valid alternatives come from rotation and mirrored versions. For 3×3 this yields 8 equivalent forms of Lo Shu.

Backtracking or constraint reasoning

In partially filled puzzles, a constraint-first approach is often best: place candidates, test whether all lines can still reach the target, backtrack when needed, and continue. This is what digital solvers do and what advanced players do manually with logic.

How to solve an unknown magic grid
  • Compute the target first. Every move is guided by this number.
  • Complete nearly filled rows/columns first. One missing value is usually forced by subtraction.
  • Prioritize intersecting cells. Cells touching multiple constraints often determine most possibilities.
  • Track remaining numbers. Remove used values from the candidate set to reduce options fast.
  • Validate at every step in all directions. A row error can block diagonals immediately.

Kognify Magic Grids and similar games

On Kognify, Magic Grids gives partial setups and asks you to complete each row, column, and diagonal to the same target. Difficulty increases by size (3×3 to 5×5) and by how few clues are shown.

If you enjoy this format, these family games are also good warmups:

Frequently asked questions

What is a magic square?
A magic square is an N×N grid where rows, columns, and diagonals all share the same sum.
How do I calculate the magic constant of an N×N square?
Use N × (N² + 1) / 2 for grids built with numbers from 1 to N².
How many 3×3 magic squares exist?
One fundamental arrangement exists; 8 variants result from symmetry operations.
How is Kognify’s game different from mathematical construction?
Kognify focuses on completing incomplete grids and applying constraints, which is different from building one from scratch.
Are magic squares related to Sudoku?
They are related by grid structure, but Sudoku is based on uniqueness constraints; magic squares are sum-focused.
Play Magic Grids
A 4,000-year puzzle, now ready to play in-browser.
Start Playing →
Premium tryout available · No commitment · Android & Web