== 
Lagrange's foursquare theorem, also known as Bachet's conjecture, was proven in 1770 by Joseph Louis Lagrange. An earlier proof by Fermat was never published. The theorem appears in the Arithmetica of Diophantus, translated into Latin by Bachet in 1621. It states that every positive integer can be expressed as the sum of four squares of integers. For example, 3 = 1^{2} + 1^{2} + 1^{2} + 0^{2} 31 = 5^{2} + 2^{2} + 1^{2} + 1^{2} 310 = 17^{2} + 4^{2} + 2^{2} + 1^{2}. More formally, for every positive integer n there exist integers x_{1}, x_{2}, x_{3}, x_{4} such that n = x_{1}^{2} + x_{2}^{2} + x_{3}^{2} + x_{4}^{2}. AdrienMarie Legendre improved on the theorem in 1798 by stating that a positive integer can be expressed as the sum of three squares iff it is not of the form 4k(8m + 7). His proof was incomplete, leaving a gap which was later filled by Carl Friedrich Gauss. In 1834, Carl Gustav Jakob Jacobi found an exact formula for the total number of ways a given positive integer n can be represented as the sum of four squares. This number is eight times the sum of the divisors of n if n is odd and 24 times the sum of the odd divisors of n if n is even (see divisor function). Lagrange's foursquare theorem is a special case of the Fermat polygonal number theorem and Waring's problem. Another possible generalisation is the following problem: Given natural numbers a, b, c and d, can we solve (*) n = ax_{1}^{2} + bx_{2}^{2} + cx_{3}^{2} + dx_{4}^{2} for all positive integers n in integers x_{1}, x_{2}, x_{3}, x4? The case a=b=c=d=1 is answered in the positive by Lagrange's foursquare theorem. The general solution was given by Ramanujan. He proved that if we assume, without loss of generality, that a ≤ b ≤ c ≤ d then there are exactly 54 possible choices for a, b, c and d such that (*) is solvable in integers x_{1}, x_{2}, x_{3}, x_{4} for all n. (Ramanujan listed a 55th possibility a=1, b=2, c=5, d=5, but in this case (*) is not solvable if n=15. [1]) See also * Euler's foursquare identity References * Ireland and Rosen (1990). A Classical Introduction to Modern Number Theory. SpringerVerlag. ISBN 038797329X. Links * Proof at PlanetMath.org Retrieved from "http://en.wikipedia.org/"

