# Magic Square Calculator

URL: https://speedycalculator.com/calculators/math/magic-square/
Last updated: 2026-11-08

> The magic square calculator builds an n × n magic square (n = 3 to 12) using the numbers 1 to n², in which every row, column and both diagonals add up to the same magic constant.

## Inputs

- Size of the square n

## Results

- Magic square
- Magic constant
- Sum of all numbers

## Formula

```
Magic constant M = n(n² + 1) / 2
```

## Explanation

Magic squares have fascinated people for millennia, from the Chinese Lo Shu square to Dürer's engraving Melencolia I. They are a playground for number patterns and a classic puzzle.

### How to use the Magic Square Calculator

- **Size of the square n**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

Odd sizes use the Siamese (de la Loubère) method, sizes divisible by 4 use the complement pattern on the diagonals, and other even sizes use Strachey's method of combining four odd squares.

## Worked example

Inputs: Size of the square n: 4.

Results: **Magic square = 16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1**; Magic constant = 34; Sum of all numbers = 136.

## Key terms

- **Magic constant**: The common sum of each row, column and diagonal.

## FAQ

**What is the magic constant of a 3 × 3 square?**
15.

**Is there a 2 × 2 magic square?**
No, it is impossible with distinct numbers 1 to 4.

**How many 3 × 3 magic squares are there?**
Essentially one; the others are its rotations and reflections.

**What is Dürer's magic square?**
A 4 × 4 square from 1514 whose bottom row contains the year, 15 14.


## Sources

- [Wolfram MathWorld: Magic square](https://mathworld.wolfram.com/MagicSquare.html)
- [OpenStax: Contemporary Mathematics](https://openstax.org/details/books/contemporary-mathematics)
