Magic Square Calculator

Choose build or check, then enter a size or a square.

A whole number from 3 to 15.

Try

Result

You enteredn=4n = 4

[16231351110897612414151]\displaystyle \begin{bmatrix} 16 & 2 & 3 & 13 \\ 5 & 11 & 10 & 8 \\ 9 & 7 & 6 & 12 \\ 4 & 14 & 15 & 1 \end{bmatrix}

Magic constant

34\displaystyle 34

Method

doubly-even method\displaystyle \text{doubly-even method}
Show the work
  1. Magic constant

    The numbers 11 to n2n^2 add up to n2(n2+1)/2n^2(n^2 + 1)/2, and shared out over nn rows that gives the sum every row, column and diagonal must have.

    M=n(n2+1)2=4(42+1)2=4×172=34\begin{aligned} M &= \dfrac{n\left(n^{2} + 1\right)}{2} \\ &= \frac{4\left(4^{2} + 1\right)}{2} \\ &= \frac{4 \times 17}{2} \\ &= 34 \end{aligned}
  2. Construction by the doubly-even method

    Because n=4n = 4 is a multiple of 44 (doubly even), write 11 to 1616 along the rows, then replace every number on the diagonals of each 4×44 \times 4 block by 1717 minus itself.

  3. Checking the sums

    Adding along each of the 44 rows gives 3434 every time, and the columns and both diagonals agree.

    34, 34, 34, 3434,\ 34,\ 34,\ 34
  4. Result

    The 4 by 4 magic square has constant 3434.

Worked examples