# How to Determine a Magic Constant in a Magic Square?

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$.

• @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? – warspyking Dec 5 '14 at 1:28

## 2 Answers

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} \\$

• $n\left(\frac{n^2+1}{2}\right) = 1$ at $n=1,$ so this could be simplified to if $n \ne 2$ and "else". – Display name Nov 24 '18 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.

• That last sentence didn't answer my question at all… – warspyking Dec 5 '14 at 0:54
• The equation before it gives a formula for the magic constant of an $n\times n$ magic square in terms of the size. – Julian Rosen Dec 5 '14 at 0:55
• What would the result of 2 be? – warspyking Dec 5 '14 at 0:59
• 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. – Julian Rosen Dec 5 '14 at 1:05
• The Wikipedia article on magic squares says they exist for all sizes except $2\times 2$ – Julian Rosen Dec 5 '14 at 1:27