## Pairs and squares

This puzzle, which I posted to twitter (@puzzlecritic) a few weeks ago, is one of my variations on a problem that appeared in a mathematical discussion group on LinkedIn:

Find three different positive integers such that the sum of any two is a square.

This seems innocuous; you just have to find three numbers that work, and you’re not even asked to prove anything. And yet it is possible to spend a frustratingly long time trying and failing to come up with an answer. Even if you do stumble upon a solution, you might be left wondering if there are any more, and if so how you might go about finding them all.

Small examples do exist, but the matter can be settled in complete generality with algebra. We are looking for positive integers $a,b,c,x,y,z$ satisfying the following:

$a+b=x^2$

$b+c=y^2$

$c+a=z^2$

Now, at the moment it looks like we just don’t have enough information: the numbers being asked for are $a, b$ and $c$, but the equations above have six unknowns, not three.

Oh well. Let’s see what happens when we solve them simultaneously for $a, b$ and $c$:

$a=\dfrac{x^2-y^2+z^2}{2}$

$b=\dfrac{x^2+y^2-z^2}{2}$

$c=\dfrac{-x^2+y^2+z^2}{2}$

We now have expressions for our three original numbers; unfortunately they’re in terms of $x, y$ and $z$. But wait: we are now completely free to pick positive integer values for $x, y$ and $z$, and this will give us our three numbers $a, b$ and $c$! Problem solved.

Great, so let’s pick $x=1, y=2, z=3$. We’re so close we can taste the finish line. Our values for $a, b$ and $c$ are…

$a=3, b=-2, c=6$.

Oh dear. Our numbers were supposed to be positive, and -2 is definitely not positive.

You can’t be sure you can solve a problem until you’ve seen it all the way through. We are not completely free to pick values for $x, y$ and $z$ after all: we require the sum of the smaller two to be greater than the third and largest square. Otherwise one of $a, b$ and $c$ will be negative, as in the failed attempt above.

Okay, point made; let’s finish this. 16, 25 and 36 are all squares, and 16+25 is greater than 36. So let’s pick $x=4, y=5, z=6$, and we obtain…

$a=13.5, b=2.5, c=22.5$

Oh come on! What now? Just when you thought the hurdle had been overcome, another one pops up.

When you see it, it’s obvious: if you ever find yourself dividing by 2, you had better make sure that the number you started with was even, or you won’t have an integer left after the calculation, as in failed attempt number 2.

At this stage, you might begin to question if anything else could go wrong. Actually, there is something – we can ensure positivity and integer values, but how do we know our $a,b$ and $c$ will all be different?

A bit of thought resolves this quickly: looking at the equations we had to solve, two of $a,b$ and $c$ will be equal only if two of $x,y$ and $z$ are equal.

Alright, we finally have this sussed (hopefully). Pick different values of $x,y$ and $z$ so that the squares of the smaller two have a sum greater than the square of the third, and so that all the numerators on the right hand side of the second set of equations above are even. This is equivalent to the condition that \$x^2+y^2+z^2\$ is even.

Looking at small numbers, we find that $x=5, y=6, z=7$ satisfies all the necessary conditions, and at long last we have a solution:

$\fbox{a=19, b=6, c=30}$

After all that, it might feel like it would have been quicker just to try loads of numbers. The benefit of the algebraic approach is that now we know how to find all the solutions.

It’s such a simple puzzle, but an awful lot of good learning can come out of it. I will be asking pupils to have a go for many years to come.