This page was formerly at:

Linux Programs macOS Programs Bordered Magic Rectangles Magic Square Art

Magic Squares


A normal magic square of order n contains the integers 1, 2, ..., n² arranged such that the sum of the numbers in any row, column, or main diagonal is the same:


This is called the magic constant.

All unqualified references to magic squares on this site mean normal magic squares.

Programs on the Downloads page make many specific types of magic squares. Magic squares can also be made with MagicRectangles, the CompleteSquare utility, and SODLS.


Subtracting the average of the numbers in the square, (n²+1)/2, from each number, yields a skeleton square of normalized numbers, "the bones", consisting of positive and negative numbers, and, for odd order squares, 0. This is a convenient way of seeing symmetry in the square. It can also facilitate square construction, transforms, and analysis. Conveniently, commonly used sums like the magic constant and the complementary pair total, are 0 in the bones.

Note: In many places on this site, the minus sign and ½ are omitted from bones images. Plus and minus numbers are generally distinguished by red and blue colors.

Example Squares: Order 3, 4, 5

Order 3 Square

There is 1 distinct, that is, not including rotations and reflections, magic square of order 3. It was known to the ancient Chinese, who called it the Lo Shu.

Order 3 square and bones

Notice that the complementary pairs of the square, i.e., pairs of numbers whose sum is n² + 1, appear as ± pairs in the bones.

Order 4 Squares

There are 880 distinct magic squares of order 4. These were enumerated by Bernard Frénicle de Bessy in the 17th century. The square shown here is called Dürer's magic square.

Order 4 square and bones

Order 5 Squares

There are 275,305,224 distinct magic squares of order 5. The number was first computed by Richard Schroeppel in 1973.

Order 5 square and bones

Order 6 Squares

There are 17,753,889,197,660,635,632 distinct magic squares of order 6. These were counted in 2024 by Professor Hidetoshi Mino.

The square shown here is near-associative, i.e., only two complementary pairs are not center-symetric.

Order 6 square and bones

Freeware Disclaimer

The software on this site may be used freely.
You should use only if you agree to the freeware disclaimer.

Please send errata or comments to Harry White,


Andrews, W.S. "Magic Squares and Cubes"

Boyer, Christian "multimagic squares site"

Breedijk, Arie "Magic square"

Campbell, Dwane H. and Keith A. Campbell "WELCOME TO MAGIC CUBE GENERATOR"

Danielsson, Holger "Magic Squares"

Darling, David "magic square"

de Winkel, Aale "The Magic Encyclopedia"

Gaspalou, Francis "Magic Squares"

Golunski, Bogdan "NUMBER GALAXY"

Grogono, Alan W. "Grogono Magic Squares"

Heinz, Harvey "Magic Squares"

Knecht, Craig "Knecht Magic Squares"

Meyer, H.B. "Magic Squares and Cubes"

Mino, Hidetoshi, Ph.D. Professor emeritus, University of Yamanashi, Japan

Nakamura, Mitsutoshi "Magic Cubes and Tesseracts"

Öfverstedt, Johan "Water Retention on Magic Squares Solver"

Suzuki, Mutsumi "Magic Squares"

Taneja, Inder J. "Numbers Magic"

Trump, Walter "Notes on Magic Squares"

Weisstein, Eric W. "Magic Square." From MathWorld--A Wolfram Web Resource.

Walkington, William "Magic Squares, Spheres and Tori"