Since it they are two squares, one inside the other, we can express the total number of soldiers as a difference of squares. In this case:
20² - 8² and 16² -10²
A simpler version of the difference of squares is a²-b² = (a+b)(a-b)
So:
20² - 8² = (20+8)(20-8) = 28x12 = 336
16² - 10² = (16+10)(16-10) = 26x6 = 156
To order 960 soldiers, we can take an approach based on another problem, "Difference of Two Squares" (http://nrich.maths.org/11120). It can be solved applying one of the conclusions I came to while solving it
If we divide the square up like in the picture, we can say that:
(a+b)²-(b-a)² = 960
[(a+b)+(b-a)][(a+b)-(b-a)] = 960
[(a+b)+(b-a)] = b + b + a - a = 2b
[(a+b)-(b-a)] = b - b + a + a = 2a
(2b)(2a) = 960
4ab = 960
ab = 240
This makes the problem a lot easier, as now it is just the factors of 240.
240 = {1 x 240}, {2 x 120}, {3 x 80}, {4 x 60}, {5 x 48}, {6 x 40}, {8 x 30}, {10 x 24}, {12 x 20}, {15 x 16}
The rest of the pairs are excluded because b>a, and they're effectively the same squares [eg. {15 x 16} = {16 x 15}]
So the possible squares are {Big square, small square}:
{241, 239}, {122, 118}, {83, 77}, {64, 56}, {53, 43}, {46, 34}, {38, 22}, {34, 14}, {32, 8}, {31, 1}
These are all the possible ways in which 960 can be arranged in this 'hollow square' formation.
4ab = [Number of Soldiers]
From this we can see that only battalions with sizes that are multiples of 4 can be arranged. It also generalises this problem, so all the possible hollow square formations can be obtained!