A magic square consists of the numbers $1,2,\ldots,m^2$ placed into $m\times m$ square grid, so that every row, column, and both diagonals have the same sum. The magic constant of the square is this common sum.

Based on the dimensions of an $m\times m$ square, can you determine what the magic constant is? If so, how can you do that? If not, please explain why it isn't possible.

For example, here are some magic square "magic constants";

$1\times 1\,\to\, 1 $
$2\times 2 \,\to nil$
$3\times 3\,\to \,15$
$4\times4\,\to\, 34$
$5\times 5 \,\to\, 65$

How can you determine the $6\times 6$, $7\times7$, etc. just from the dimensions?

Please note; I'm not asking for how to solve an $m\times m$ magic square, nor do I want a "trial and error" answer. I want a mathematical based answer explaining how to figure out the magic constant of a magic square with the dimensions $m\times m$.

  • $\begingroup$ @Jul For future reference, without enough rep, your edits have to be approved, so feel free to edit, your "permission" is the approval of the OP or mods. If you do however have enough rep to edit without permission, you should know what you're doing now shouldn't you? $\endgroup$
    – warspyking
    Dec 5, 2014 at 1:28

2 Answers 2


According to wikipedia, you're talking about a Magic Sum. Let's say the formula for finding this number is:

$\text{MagicSum} = \begin{cases} 1 & \mbox{if }n = 1 \\ n\Big( \frac{n^2 +1}{2}\Big) & \mbox{if }n> 2 \\ \text{undefined} & \mbox{else}\end{cases} \\ $

  • 1
    $\begingroup$ $n\left(\frac{n^2+1}{2}\right) = 1$ at $n=1,$ so this could be simplified to if $n \ne 2$ and "else". $\endgroup$ Nov 24, 2018 at 2:00

Given an $n\times n$ magic square, write $M_n$ for its magic constant. There are $n$ rows, each of which has sum $M_n$, so the sum of all the entries in the square is $n \cdot M_n$. Each whole number between $1$ and $n^2$ appears once, so $$ \begin{gather} n\,M_n=1+2+\ldots+n^2=\frac{n^2(n^2+1)}{2},\\ M_n = \frac{n(n^2+1)}{2}. \end{gather} $$ In particular, every $n\times n$ magic square has the same constant.

  • $\begingroup$ That last sentence didn't answer my question at all… $\endgroup$
    – warspyking
    Dec 5, 2014 at 0:54
  • $\begingroup$ The equation before it gives a formula for the magic constant of an $n\times n$ magic square in terms of the size. $\endgroup$ Dec 5, 2014 at 0:55
  • $\begingroup$ What would the result of 2 be? $\endgroup$
    – warspyking
    Dec 5, 2014 at 0:59
  • 2
    $\begingroup$ That's what I mean by "vacuosly true". A statement about every object of a certain kind is always true if there are no objects of that kind. $\endgroup$ Dec 5, 2014 at 1:05
  • 1
    $\begingroup$ The Wikipedia article on magic squares says they exist for all sizes except $2\times 2$ $\endgroup$ Dec 5, 2014 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.