# Magic Square

## Magic Square

Table of whole numbers arranged in a square (3 × 3, 4 × 4, etc.) so that the sum of the numbers vertically, horizontally, and diagonally is always the same.

If the whole numbers used are consecutive from 1 to n², we call this a normal magic square of n by n.

The sum of the number on the same line or in the same column or on a diagonal is called the magic sum or the density of the magic square.

We sometimes use the term heterogeneous square or heterosquare for a square grid of numbers where the sum of the number situated vertically, horizontally, or diagonally, is never the same.

If a heterosquare is formed by a sequence of consecutive whole numbers from 1 to $$n^2$$, we call it a normal heterosquare.

We also sometimes use the term antimagic square for a heterosquare where the sums of the numbers found on the lines, diagonals, and columns form a sequence of whole numbers.

### Property

To calculate the magic sum S of a magic square formed by numbers from 1 to $$n$$ including $$n^2$$ cases, we can use the formula: $$S\space = \space \dfrac{n(n^2+1)}{2}$$.

### Examples

• A normal 3 × 3 magic square with a magic sum equal to 15:
• A normal heterosquare:
• An antimagic square: Here, the sums of the lines, columns, and diagonals form a sequence of whole numbers from 29 to 38.