boriel.com

Hacks, science and curiosities

Magic Square

– 🕓 3 min read

This week El Pais' math challenge was easier to solve than previous ones (maybe that's why I resolved it without using the computer this time :D).

The problem is the following: get a product magic square, that is, a 3x3 square whose product for numbers in every row, column or diagonal gives the same (unknown) amount. All numbers are unrepeated positive integers. It's known that the number in the center cell is 15.

My approach was to assign each cell a variable name:

$$ \large{ \begin{array}{|c|c|c|} \hline a & b & c \\\hline d & 15 & f \\\hline g & h & i \\\hline \end{array}} $$

This way I got equations like:

$$ \begin{align} a * b * c & = a * d * g \\ a * b * c & = a * 15 * i \\ a * b * c & = d * 15 * f \\ a * d * g & = g * h * i \\ ... & \end{align} $$


which allows some terms to be cancelled and, after some operations, I got the following magic square (or the like, rotations are equivalents):

$$ \large{ \begin{array}{|c|c|c|} \hline \frac{15^3}{b·c} & b & c \\\hline \frac{b·c^2}{15^2} & 15 & \frac{15^4}{b·c^2} \\\hline \frac{15^2}{c} & \frac{15^2}{b} & \frac{b·c}{15} \\\hline \end{array}} $$

Now we see the product of any row, column or diagonal gives the same result (as requested), and that such result is \(15^3 = 3375\). This was the unknown product. Even more, since cells can only have positive integers, the number of possible solutions is finite (in fact unique if rotations are excluded). We can also see that both b and c must be a factor of \(15^2\), or in other words, both \(b\) and \(c\) must be one of \(1, 3, 5, 3^2, 3 * 5\) (already in the center), \(5^2, 3^2 * 5, ...\). That is every possible combination of possible product of \(3^x * 5^y\) (with both \(x\) and \(y\) being one of \(0, 1, 2, 3\)). There are 16 possible combinations. Let's start supposing \(b = 1\), then the resulting square is:

$$ \large{ \begin{array}{|c|c|c|} \hline \frac{15^3}{c} & 1 & c \\\hline \frac{c^2}{15^2} & 15 & \frac{15^4}{c^2} \\\hline \frac{15^2}{c} & 15^2 & \frac{c}{15} \\\hline \end{array}} $$

Right-lowest cell reveals that 15 must be a factor of \(c\) (and \(c\) cannot be 15, because the upper right cell value would be the same as the one in the center). The lowest left-most cell also tell us that \(c\) is a factor of \(15^2\) (which is \(3^2 * 5^2\)). This means c must be a product of 3 or 9 per 5 or 25 (only 3 combinations possible, since \(3 * 5 = 15\) has already been discarded). I tried with \(9 * 5 = 45\) and... eureka! \(c = 45\). I replaced \(c\) by its value and this is the magic square:

$$ \large{ \begin{array}{|c|c|c|} \hline 75 & 1 & 45 \\\hline 9 & 15 & 25 \\\hline 5 & 225 & 3 \\\hline \end{array}} $$