Which whole numbers are expressible as sums of two (integer) squares?

Here’s a theorem that completely answers the question, due to Fermat:

A number N is expressible as a sum of 2 squares if and only if in the prime factorization of N, every prime of the form (4k+3) occurs an even number of times!

Examples: 245 = 5*7*7. The only prime of the form 4k+3 is 7, and it appears twice. So it should be possible to write 245 as a sum of 2 squares (in fact, try the squares of 14 and 7). But because 7 appears only once in 42=2*3*7, it is impossible to write 42 as the sum of two squares.

A corollary of this fact is that every prime of the form (4k+1) can be written as the sum of two squares.

**Presentation Suggestions:**

See if your students can figure out how to write 245 as the sum of two squares, using their knowledge from the Fun Fact Products Of Sums Of Two Squares and writing 5, and 49 as the sum of two squares.

**The Math Behind the Fact:**

Well, if not every number can be written as a sum of two squares, perhaps a larger number of squares will suffice? Can every number be written as the sum of 3 or 4 squares? See the Fun Fact Sums of Three and Four Squares for more on these questions.

**How to Cite this Page:**

Su, Francis E., et al. “Sums of Two Squares.” *Math Fun Facts*. <https://www.math.hmc.edu/funfacts>.

**Fun Fact suggested by: **

Lesley Ward