Skip to content
FiftyCalc Free calculators for all 50 states

Magic Square Calculator

Test cases replayed : 3 of 3 match · Methodology · No outside source listed

Enter the order n for the magic constant, and a first number and a step to fill a 3×3 magic square.

Result

Sample figures

Magic constant of an n×n square using 1 to n²—

3×3 row 1, left —

  • 3×3 row 1, middle—
  • 3×3 row 1, right—
  • 3×3 row 2, left—
  • 3×3 row 2, middle—
  • 3×3 row 2, right—
  • 3×3 row 3, left—
  • 3×3 row 3, middle—
  • 3×3 row 3, right—
  • Sum of every row, column and diagonal of the 3×3 square—

Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.

Magic Square Calculator

Order n of the square (3 or more; for the magic constant): enter 3 or more. Prefilled example: 3.

3×3 square: smallest number: enter a number. Prefilled example: 1.

3×3 square: step between consecutive numbers: enter a number. Prefilled example: 1.

How to use this calculator

Fill in the fields in this order; each step takes you to its field.

  1. Order n of the square (3 or more; for the magic constant): enter 3 or more.
  2. 3×3 square: smallest number: enter a number.
  3. 3×3 square: step between consecutive numbers: enter a number.
  4. Read the result: Magic constant of an n×n square using 1 to n²; the panel also shows 3×3 row 1, left, 3×3 row 1, middle, 3×3 row 1, right, 3×3 row 2, left, 3×3 row 2, middle, 3×3 row 2, right, 3×3 row 3, left, 3×3 row 3, middle, 3×3 row 3, right and Sum of every row, column and diagonal of the 3×3 square.

How this calculator works

A normal magic square of order n holds the numbers 1 to n² once each. Their total is n²(n² + 1) ÷ 2 and it splits evenly over n rows, so every row, column and main diagonal adds up to the magic constant n(n² + 1) ÷ 2.

The 3×3 square follows the classic Lo Shu arrangement (4 9 2 / 3 5 7 / 8 1 6). Replacing each number k by a + (k − 1) × d keeps every line equal, with the sum 3a + 12d.

The formula

  1. K=n×(n2+1)2
Symbols used in the formula
SymbolMeaning
nOrder n of the square (3 or more; for the magic constant)
KMagic constant of an n×n square using 1 to n²

Worked example

Order n of the square (3 or more; for the magic constant)3
3×3 square: smallest number1
3×3 square: step between consecutive numbers1
3×3 row 1, left4
3×3 row 1, middle9
3×3 row 1, right2
3×3 row 2, left3
3×3 row 2, middle5
3×3 row 2, right7
3×3 row 3, left8
3×3 row 3, middle1
3×3 row 3, right6
Sum of every row, column and diagonal of the 3×3 square15
  1. K=3×(32+1)2=15

Magic constant of an n×n square using 1 to n² 15

Each step uses the unrounded value of the step before it; figures on this page are rounded for display.

Frequently asked questions

What is the magic constant of a 4×4 magic square?

4 × (16 + 1) ÷ 2 = 34. For 3×3 it is 15 and for 5×5 it is 65.

What is the 3×3 magic square with 1 to 9?

4 9 2 / 3 5 7 / 8 1 6: every row, column and diagonal adds up to 15, with 5 in the center.

Related calculators