Category

Magic Square Calculator — Generate 3×3 to 10×10 Magic Squares

Generate a magic square of any order from 3×3 to 10×10 instantly. Choose the starting number and common difference, then see the magic constant, the completed square with highlighted diagonals, and the formula. Uses the Siamese, criss-cross, and Strachey construction methods.

0 calculations

Calculation Parameters

Enter Parameters

Fill in the form on the left and click "Calculate"

Sprinkle some magic into your math

Welcome to the magic square calculator! In this tool we will lead you through an exploration of one of the oldest and most charming puzzles in mathematics. Enter an order (the number of rows and columns), pick a starting number and a common difference, and the calculator will instantly build a genuine magic square, show you its magic constant, and highlight the diagonals so you can verify the magic with your own eyes. Abracadabra! 🎩

What is a magic square?

A magic square is a square grid of integers arranged so that their positions respect three rules:

  • No numbers repeat — every cell holds a different value.
  • Every row and every column sums to the same value — this shared total is called the magic constant (or magic sum).
  • Both main diagonals add up to that same magic constant too.

The order n of a magic square is simply the number of cells along one side. A classic magic square of order n uses the whole numbers from 1 to n², and its magic constant is:

M = n(n² + 1) / 2

Our calculator goes one step further: instead of forcing you to use 1, 2, 3, …, it lets you start anywhere and count up in steps of any size d. The entries then form an arithmetic progression, and the magic constant becomes:

M = n · a + d · n(n² − 1) / 2

where a is the first number and d is the common difference. Set a = 1 and d = 1 and you recover the classic formula above.

The history of magic squares

Where there is magic, there is the attention of humanity — and magic squares are no exception. The earliest records of a 3×3 magic square, known in China as the Lo Shu square, date back more than two thousand years. Over the following centuries, cultures across Asia, the Islamic world, and Europe explored these curiosities, weaving them into art, astrology, and mathematics. The famous engraving Melencolia I by Albrecht Dürer (1514) even hides a 4×4 magic square whose bottom row conveniently spells out the date.

🙋 A small disclaimer: magic squares are not actually magic! They are simply a matter of numbers and clever arrangement — close to magic, but entirely real.

Properties of magic squares

Beyond the three basic rules, mathematicians have discovered many special families of magic squares:

  • Pandiagonal magic squares — even the "broken" diagonals that wrap around the edges add up to the magic constant.
  • Associative magic squares — every pair of cells symmetric about the center sums to n² + 1.
  • Most-perfect magic squares — a doubly special square that is both pandiagonal and has extra 2×2 sub-square symmetries.

🔎 A broken diagonal is an offset diagonal that wraps around a corner of the square. Imagine placing two copies of the square side by side: a broken diagonal starts in one copy and finishes in the next.

The elusive 2 by 2 magic square

Here is a fun fact you can test above: there is no 2×2 magic square (other than the trivial one where all cells are equal, which breaks the "no repeats" rule). With only four cells, the requirements that the rows, columns, and diagonals all share the same sum force the numbers to be equal — so a proper 2×2 magic square simply cannot exist. Type 2 into the order field and the calculator will politely explain this to you. Magic begins at order 3!

How to calculate a magic square: from 3×3 to infinity

There is no single recipe that works for every size, so our calculator automatically picks the right classical construction based on the order:

  • Odd orders (3, 5, 7, 9, …) — the Siamese method (also called the method of De la Loubère). Start in the top-middle cell and keep moving diagonally up-and-right, dropping down one row whenever a cell is already taken.
  • Doubly even orders (4, 8, …, multiples of 4) — the criss-cross method. Fill the grid 1 to n² in order, then flip the numbers that sit on the diagonals of each 4×4 block to their complement n² + 1 − value.
  • Singly even orders (6, 10, …) — the Strachey method. Split the square into four quadrants, build a smaller odd magic square in each, then swap a handful of columns to balance everything out.

For example, the smallest magic square, the 3×3 Lo Shu, has a magic constant of 15:

816
357
492

Every row, column, and diagonal adds up to 15 — go ahead and check!

Pulling squares out of a hat

Once you have one magic square, you can conjure up endless variations without changing its magic:

  • Rotate or reflect the grid — the magic constant stays the same.
  • Add the same number to every cell — this is exactly what the "starting number" field does; the constant simply shifts by n times that number.
  • Multiply every cell by the same factor — the "common difference" field does this; the constant scales in step.

That is why our calculator can produce a magic square of ruble amounts, dollar prices, or any evenly spaced sequence you like, all while keeping the magic perfectly intact.

How to use our magic square calculator

  1. Order — enter how many rows and columns you want (from 1 up to 10). Remember, 2 has no solution!
  2. Starting number — the smallest value in the square (default 1). It can be negative if you like.
  3. Common difference — how much each successive number increases (default 1). Any non-zero integer works.
  4. Press Calculate and read off the magic constant, the completed square (diagonals highlighted), and the formula breakdown.

FAQs

How many 3×3 magic squares are there? Up to rotations and reflections, there is exactly one 3×3 magic square using the numbers 1–9 — the Lo Shu. Counting all eight rotations and mirror images gives 8 arrangements.

What is the magic constant of a 4×4 magic square? Using 1–16 it is 34. In general it is n(n²+1)/2.

Can a magic square use decimals or currency amounts? Yes. Because the magic property survives adding and multiplying, you can label the cells with prices in US dollars, Russian rubles, euros, or any evenly spaced values — just choose the starting number and common difference to match.

A note on units, systems of measurement, and currencies

A magic square is a pure arrangement of integers: the "magic" is a property of the numbers themselves, not of any physical quantity. Because of this, the square is identical whether you imagine the cells measured in the US customary / imperial system or the metric (SI) system — the pattern does not depend on units at all. If you decide to give the entries a monetary meaning, you are free to read them as US dollars ($), Russian rubles (₽), euros (€), British pounds (£), or any other world currency: simply pick the starting number and common difference in that currency, and the magic constant will be expressed in the very same currency. The magic never changes — only the label on the numbers does.

Calculation History

Loading...