Expressing an integer as the sum of three squares

I'm trying to determine if 1317 and 116 can be written as the sum of three squares?

I have the condition that if it is not of the form $4^{\alpha}(8k+7)$ then it can be written as a sum of three squares, but how do I use this condition to work it out?

Thank you


Solution 1:

Obviously both numbers are not of the given form, hence the theorem (of Gauss) says that both numbers are representable as a sum of three squares - which is indeed true, and easy to compute:

$$ 1317=4^2+25^2+26^2 $$

and

$$ 116=10^2+4^2+0^2 $$

Solution 2:

1317 is not divisible by 4, and 116 is divisible by 4 but not 16. So all you need to do is compute 1317 mod 8 and 116/4 = 29 mod 8, and see if you get 7. If not, then you know the number can be written as a sum of 3 squares, according to your result. The real question is whether your condition is if and only if, i.e. if a number IS equal to 7 mod 8, then do you know for sure that it CANNOT be written as a sum of 3 squares?