# Fermat's theorem on sums of two squares composite number

Suppose that there is some natural number $a$ and $b$. Now we perform $c = a^2 + b^2$. This time, c is even.

Will this $c$ only have one possible pair of $a$ and $b$?

edit: what happens if c is odd number?

• Have you seen this answer? It gives you results related to the number of ways of writing a given $n$ as a sum of two squares, subject to sundry conditions. – Arturo Magidin Jul 11 '12 at 15:11

Not necessarily. For example, note that $50=1^2+7^2=5^2+5^2$, and $130=3^2+11^2=7^2+9^2$. For an even number with more than two representations, try $650$.

We can produce odd numbers with several representations as a sum of two squares by taking a product of several primes of the form $4k+1$. To get even numbers with multiple representations, take an odd number that has multiple representations, and multiply by a power of $2$.

To help you produce your own examples, the following identity, often called the Brahmagupta Identity, is quite useful: $$(a^2+b^2)(x^2+y^2)=(ax\pm by)^2 +(ay\mp bx)^2.$$

If a,b are both even or both odd, c is even.

c will be odd iff a and b are opposite parity.

Let a=2A and b=2B+1, then c≡1(mod 4).

So if c≡3≡-1(mod 4), there will be no solution.

In other way, we can take (a,b)=d, then $d^2|c$ , let $C^2=d^2.c$

Let $\frac{a}{A}=\frac{b}{B}=d$, clearly (A,B)=1

Then, A & B are both not even.

The case of A,B being opposite parity has been dealt above.

If A & B are both odd, let A=2m+1, B=2n+1.

$A^2+B^2=(2m+1)^2+(2n+1)^2=2(p^2+q^2)$ (say)=$(p+q)^2+(p-q)^2$

Then p=m+n+1, q=m-n and p+q=2m+1 is odd=> p & q are of opposite parity.

So, the problem boils down to finding A,B such that (A,B)=1 and A,B are of opposite parity.

Clearly, C≡1(mod 4) is a necessary condition for solubility.

Proof of sufficiency

Brahmagupta Identity can used to prove that if C is a product of n primes of the form 4r+1, it can be represented as the sum of two squares in $2^{n-1}$ ways.