I came across this theorem one time and found it especially striking. I even told my friends who supposedly dislike math about it, and they were amazed, trying to calculate values for various numbers.

Lagrange's Four-Square Theorem states that any positive integer can be expressed as the sum of four perfect squares. Try this for numbers like 7, 31, 326. While we know of course of numbers that can be expressed as one square (perfect squares), we know less about numbers that can be expressed as the sum of two or three squares. (Note that 0 is a square). Try to work out this theorem for some other numbers? Can you find any that are the sum of only two squares or only three squares? Is there any pattern to these numbers?

While the proof of the theorem is beyond the scope of the Cosines Group, you can find the proof on the Wikipedia page with the same name.

As a Computer Science extension, can you create a code that will find the four squares that sum up to any given inputted number? Perhaps you can use this to locate any patterns in the system.

Feel free to post any solutions, ideas, questions, extensions, or code below.

Easy Math Editor

`*italics*`

or`_italics_`

italics`**bold**`

or`__bold__`

boldNote: you must add a full line of space before and after lists for them to show up correctlyparagraph 1

paragraph 2

`[example link](http://brilliant.org)`

`> This is a quote`

Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.`2 \times 3`

`2^{34}`

`a_{i-1}`

`\frac{2}{3}`

`\sqrt{2}`

`\sum_{i=1}^3`

`\sin \theta`

`\boxed{123}`

See full formatting guide