It also appears that the opposite is mostly true: if C has a prime factor p that cannot be written as the sum of the squares of two integers then C itself cannot be the sum of the squares of two integers. The exception is cases where p appears as a factor of C an even number of times, in which case x and y will both also have p as a factor exactly half the number of times that C does.

Is this a well known fact that I'm not aware of, or is there a proof of this somewhere? It's not at all clear to me why this appears to be true. For example, 2 can be written 1^2 + 1^2 = 2, and 2^2 + 3^2 = 13. If we take 2*2*13 = 52 we get 4^2 + 6^2 = 16 + 36 = 52. The factors 2*2*13 have no obvious relationship with 4 and 6, yet we see that they are connected somehow. And this is not an isolated case, I tested numbers up to 440 and found no exceptions to this fact aside from the already mentioned case.

]]>