Can any number of squares sum to a square?

"Is any $k$ possible?" An easy route to "Yes": You know from the Pythagorean theorem that two squares can add to a perfect square. $$c^2=a^2+b^2$$

$c^2$ must be either odd or even. If odd, it is the difference between two consecutive squares. $$c^2=2n-1=n^2-(n-1)^2$$ If even, $c^2$ is divisible by $4$ and is also the difference between two squares. $$c^2=4n=(n+1)^2-(n-1)^2$$ So in either case, $c^2$ equals the difference between two squares. $$c^2=r^2-s^2 \\ r^2=c^2+s^2=a^2+b^2+s^2$$ Here, $r^2$ is the sum of three squares.

This can be repeated indefinitely, increasing by one the number of squares in the sum which adds to a square. There is no limit to the number of squares that can be accumulated in the sum.


Yes, $k$ can be arbitrary. Define a sequence$$a_1:=3,\,a_{k+1}:=\frac12\left(a_k^2+1\right)$$ of odd positive integers (since $\frac12((2n+1)^2+1)=2(n^2+n)+1$), so$$a_{k+1}^2-a_k^2=\frac14\left[(a_k^2+1)^2-4a_k^2\right]=\left[\frac12(a_k^2-1)\right]^2$$is a perfect square. Now define$$b_1:=3,\,b_{k+1}:=\frac12(a_k^2-1)$$so $a_k^2=\sum_{i=1}^kb_i^2$ for all positive integers $k$. The sequence $a_n$ is called the Pythagorean spiral or OEIS A053630.


Here is a geometric solution (for $k > 5$).

The following are solutions for 6, 7, and 8 squares.

enter image description here

We can replace a square in each of these with four equal size squares to find a tiling with 3 more squares, so we can get 9, 10, and 11 squares. Repeating this we can get any number of squares larger than 5.

I show one iteration below:

enter image description here