StatGardenREF. DESK
Calculators/Maths/Magic square
Maths

Magic square calculator

Finds the magic constant of an n×n magic square and builds it for odd n via the Siamese method.

What this calculator does

Magic square works out finds the magic constant of an n×n magic square and builds it for odd n via the Siamese method. Enter your own figures above and the answer updates as you type: nothing is fixed in the code, so the result reflects exactly the numbers you supply.

The formula this calculator evaluates is printed under the tool and explained below, so you can check the working by hand or reuse it in a spreadsheet.

The formula

FormulaMagic constant M = n(n²+1) / 2, filled with the integers 1 to n²

The inputs explained

FieldWhat to enter
Square size (n, side length)A number. Starts at 5.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How the answer changes with square size (n, side length)

Every other input is held at the calculator’s starting values while square size (n, side length) varies. Select any row to load that scenario into the calculator.

How the answer changes with square size (n, side length)
Square size (n, side length)Magic constant (row/column/diagonal sum)Numbers usedGrid size
2.5151 to 93 × 3
3.75341 to 164 × 4
5651 to 255 × 5
7.52601 to 648 × 8
105051 to 10010 × 10
151,6951 to 22515 × 15