Magic squares have fascinated people for thousands of years, from ancient China to Dürer’s engraving Melencolia I. The magic square constant calculator takes the size, the first number and the step, and gives the magic constant, the sum of all the numbers, the largest number and the average.
How the calculation works
- Enter the side n of the square, the first number a and the step d. The classic square uses the numbers 1 to n², which means a = 1 and d = 1.
- The square holds the n² numbers a, a + d, a + 2d, …, a + (n² − 1)d, and each is used once.
- The sum of all the numbers is n² × (first + last) ÷ 2. In a magic square, the n rows all have the same sum, so the magic constant is that total ÷ n.
- For the numbers 1 to n², the constant is n × (n² + 1) ÷ 2. For an odd n, the average number sits at the center cell.
Example
A 5 × 5 magic square uses the numbers 1 to 25. The sum of all numbers is 25 × (1 + 25) ÷ 2 = 325, so each row, column and diagonal adds up to 325 ÷ 5 = 65. The largest number is 25, and the center cell of a classic 5 × 5 square holds the average, 13.
Why it matters
Puzzle makers, teachers and students use the constant to check a square quickly, and to know the target sum before filling in the cells. It is also a clean example of arithmetic series.
Good to know
The constant tells you what each line must add up to, but it does not build the square or prove one exists for the numbers you chose. Using steps that are not whole numbers gives constants that are not whole numbers either.
Related tools
The triangular numbers calculator covers the sums of consecutive integers, and the arithmetic series calculator handles sums of any equally spaced list.