In mathematics, Legendre's three-square theorem states that a natural number can be represented as the sum of three squares of integers if and only if n is not of the form
Previously, in 1801, Gauss had obtained a more general result,[6] containing Legendre's theorem of 1797–8 as a corollary.
In particular, Gauss counted the number of solutions of the expression of an integer as a sum of three squares, and this is a generalisation of yet another result of Legendre,[7] whose proof is incomplete.
This last fact appears to be the reason for later incorrect claims according to which Legendre's proof of the three-square theorem was defective and had to be completed by Gauss.
Gauss[10] pointed out that the four squares theorem follows easily from the fact that any positive integer that is 1 or 2 mod 4 is a sum of 3 squares, because any positive integer not divisible by 4 can be reduced to this form by subtracting 0 or 1 from it.