# Can composite numbers be uniquely written as a sum of two squares?

Let $X = a^2 +b^2$ where all the terms are positive integers and $X$ is a composite number and $\gcd(a,b)=1$ . Do there exist positive integers $c$ and $d$ other than $a$ and $b$ such that $X = c^2+d^2$ ?

By Fermat's Two Square Theorem, since $\gcd(a,b) =1$ , all prime factors of $X$ (other than $2$) must be of the form $4k+1$. I can prove that primes of the form $4k+1$ can be uniquely written as a sum of two squares, but can composites also follow the same property?

Any help will be appreciated.
Thanks.

• $65 = 8^2 + 1^2 = 7^2 + 4^2$ – MJD May 16 '16 at 14:57
• So that means it doesn't hold for composites... – Henry May 16 '16 at 14:58
• Not generally. But for $X = 2^kp$ with $p \equiv 1 \pmod{4}$ prime, you have uniqueness, and if by "positive" you mean $> 0$ rather than $\geqslant 0$, then you also have uniqueness for $4^kp^2$. – Daniel Fischer May 16 '16 at 15:03

If $N$ is a product of two numbers of the form $4k+1$, then it usually has at least two representations as a sum of two squares, because:
\begin{align} (a^2+b^2)(c^2+d^2) & = (ac-bd)^2 + (ad+bc)^2 \\ & = (ac+bd)^2 + (ad-bc)^2 \end{align}
\begin{align} 5^4\cdot 13 & = \\ 8125 & = 5^2 + 90^2 \\ & = 27^2 + 86^2 \\ & = 30^2 + 85^2 \\ & = 50^2 + 75^2 \\ & = 58^2 + 69^2 \end{align}
The smallest such example is $25 = 3^2+4^2 = 0^2+5^2$.