A Roman General is inspecting his troops. The troops arrive in eight squares each headed by a Junior Officer, who marches in front of the square. After the inspection the General insists on a more democratic arrangement, and all the troops, the Junior Officers and the General form one large square and march off the parade ground.

Each of the eight squares of troops is the same size and is a complete square with no gaps. And the square that marches off, including the extra nine men, is also a complete square with no gaps.

What is the smallest number of troops that could do this?

The solutions to this come from finding integer values for x and y in this equation.

$$8 x^2 + 9 = y^2$$

To save "leg work" we put this into a spreadsheet and scanned for solutions, and the first solution is when x = 3. Thus each square of troops contains nine men, and when combined with the nine officers (8 * 9 + 9) makes 81 which is nine squared.

This is a rather small number of troops for a General to command, so what is the next smallest number?

The next solution we found comes when x = 18. Each square of troops contains 324 men, and when combined with the nine officers (8 * 324 + 9) makes 2,601 which just happens to be 51 squared.

We pressed on, because that's the sort of people we are, and found another solution when x = 105. In this case, each square of troops contains 11,025 men, and when combined with the nine officers (8 * 11025 + 9) makes 88,209 which just happens to be 297 squared.

And there we stopped!