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
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.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Order n of the square (3 or more; for the magic constant): enter 3 or more.
- 3×3 square: smallest number: enter a number.
- 3×3 square: step between consecutive numbers: enter a number.
- 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
| Symbol | Meaning |
|---|---|
| Order n of the square (3 or more; for the magic constant) | |
| Magic 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 number | 1 |
| 3×3 square: step between consecutive numbers | 1 |
| 3×3 row 1, left | 4 |
|---|---|
| 3×3 row 1, middle | 9 |
| 3×3 row 1, right | 2 |
| 3×3 row 2, left | 3 |
| 3×3 row 2, middle | 5 |
| 3×3 row 2, right | 7 |
| 3×3 row 3, left | 8 |
| 3×3 row 3, middle | 1 |
| 3×3 row 3, right | 6 |
| Sum of every row, column and diagonal of the 3×3 square | 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.