Magic Square Calculator

Find the magic constant of an n×n magic square.

Magic constant 15
Sum of all cells 45

Formula: M = n(n² + 1) ÷ 2

Step-by-step with your numbers:
1. Values used:
2. Square size (n) = 3
3.
4. Magic constant = 15
5. Sum of all cells = 45
Did we solve your problem today?

A magic square uses the numbers 1 to n² so every row, column and diagonal sums to the same value.

The math behind it

The magic constant is M = n(n² + 1)/2. The grand total of all cells is n² (n² + 1)/2.

Worked example

A 3×3 magic square has constant 3(9 + 1)/2 = 15.

FAQ

Do all sizes have magic squares?

Yes for every n ≥ 3 (and trivially n = 1); only n = 2 is impossible.