Prove that a positive integer is composite Let $ n $ be a positive integer that can be written as a sum of two relatively prime squares in two distinct ways, that is $ n = a^2 + b^2 = c^2 + d^2 $ so that $ gcd(a, b) = gcd(c, d) = 1, $ then $ n $ is composite.
So I have successfully factored $ n $ into $ \displaystyle \frac{ac + bd}{a - d}.\frac{ac - bd}{a + d} $ and have proved that $ \displaystyle (a - d) | (ac + bd) $ and $ \displaystyle (a + d) | (ac - bd). $ So each of the $ \displaystyle \frac{ac + bd}{a - d} $ and $ \displaystyle \frac{ac - bd}{a + d} $ is an integer, but I am currently stuck on proving that $ n $ is composite. My intention is to prove that both factors of $ n $ are greater than $ 1, $ but no success at this point. Any hint or suggestion? I have tried to use the fact that $ gcd(a, b) = gcd(c, d) = 1, $ but still no progress.
Thanks.  
 A: What you ask is equivalent to showing that if $n$ is not composite then $n$ is the sum of two co-prime squares in just one way, or in no way.
The cases $n=1$ is trivial. 
If $n$ is prime, suppose $n=a^2+b^2=c^2+d^2.$ with  each of $a,b,c,d$  positive and less than $n.$ We will take all congruences  modulo $n.$
We have $b\equiv a i$ and $c \equiv \pm d i$ where $i\in Z$  and $i^2\equiv -1.$
Case (1):  $d\equiv i c .$ Then  $$n^2=(a^2+b^2)(c^2+d^2)=(a c+b d)^2+(a d-b c)^2$$ and $$a c+b d\equiv a c +i^2 a c\equiv 0\equiv a c i-a ic\equiv a d- bc.$$ So $a c+b d=n x$ and $a d-b c=n y$ with $x,y\in Z.$ We have now $$n^2=(x^2+y^2)n^2$$ while $x=a c +b d>0,$ so $x=1$ and $y=0.$ Therefore $$0=y n=a d-bc.$$ With $z=a/b,$ we have also $z=c/d,$ and $$(1+z^2)b^2 =a^2+b^2=n=c^2+d^2=(1+z^2)d^2$$ so $b=d.$ And then (of course) $a=c.$
Case (2):  $d\equiv - i c.$ We have $$p^2=(a^2+b^2)(c^2+d^2)=(a c-b d)^2+(a d+b c)^2,$$ and similarly to the methods of Case (1), we obtain $a=d$ and $b=c$. So if $n$ is not composite then $n$ is the sum of two squares in at most one way.
A: The thing you think you proved is false. You should learn to try examples when possible. In elementary number theory, this means small numbers.
Take $n = 85 = 5 \cdot 17 = 9^2 + 2^2 = 7^2 + 6^2,$ so that
$$ n=85, \;  a = 9, \; \; b = 2, \; \; c = 7, \; \; d = 6. $$ 
Then $ac+bd = 75$ and $ac-bd = 51.$ Meanwhile $a-d = 3$ and $a+d = 15.$
Your product is
$$ 85 = \frac{ac+bd}{a-d} \cdot  \frac{ac-bd}{a+d} = \frac{75}{3} \cdot  \frac{51}{15} = 25 \cdot  \frac{17}{5} $$
See $n = a^2 + b^2 = c^2 + d^2$. What are the properties of a, b, c and d? for an approach that works. 
Meanwhile, here is the original approach of Euler. Also look at footnote 27 in the second jpeg from page 360 in Dickson's History of the Theory of Numbers (Volume I).


There are popular articles on this, common author Brillhart. He says the version he gives for this problem is in Ore (1948), Number Theory and its History. First Brillhart article is December 2009, second February 2016, in the Monthly of the M.A.A. 
A: I carefully read Brillhart's first paper and realized I was unsure about the final step. So, naive or not, here is a lemma.
LEMMA Suppose, with positive integers $n,H,E,F,$ such that $$ nH = EF, $$
while
$$ 1 < E < F < n. $$
Define
$$ g = \gcd(n,E). $$
THEN  both $g > 1$ and $g < n.$
PROOF First, $g \leq E < n.$ Next, we know there are integers $x,y$ such that $$ nx - E y = g. $$
$$ nFx - EF y = gF,  $$
$$ nFx - nHy = gF, $$
$$  n(Fx - Hy) = gF > 0, $$
$$  n \leq   n(Fx - Hy), $$
$$  n \leq gF. $$
Recall $$F < n.$$
$$  n \leq gF < gn.  $$
$$ n < gn. $$
$$ 1 < g.$$
$$ \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  \bigcirc  $$
Using the letters in the original question, $n,a,b,c,d \geq 1,$ demand $a > d.$ Note that $a^2 - d^2 = c^2 - b^2 > 0.$ Next
$$ a^2 c^2 - b^2 d^2 =  a^2 c^2 - a^2 b^2 + a^2 b^2 - b^2 d^2  $$
$$ a^2 c^2 - b^2 d^2 =  a^2 (c^2 - b^2) +  b^2 (a^2 -  d^2)  $$
$$ a^2 c^2 - b^2 d^2 =  a^2 (a^2 - d^2) +  b^2 (a^2 -  d^2)  $$
$$ a^2 c^2 - b^2 d^2 =  (a^2 +  b^2) (a^2 -  d^2)  $$
$$ a^2 c^2 - b^2 d^2 =  n (a^2 -  d^2),  $$
$$    n (a^2 -  d^2) =  a^2 c^2 - b^2 d^2 = (ac-bd)(ac+bd) > 0.$$
It is not difficult to check the identity
$$  n^2 = (ac-bd)^2 + (ad+bc)^2, $$ that is one of those Brahmagupta things.
If we had $ac = bd$ we would also have $a/b = d/c,$ leading to $n = b^2 (1 + (a^2 / b^2)) = c^2 (1 + (d^2 / c^2)),$ finally $b=c$ and $a=d.$ This is ruled out, so $ac-bd \geq 1.$ 
It is also not difficult to check the identity
$$  n^2 = (ad-bc)^2 + (ac+bd)^2, $$ that is another of those Brahmagupta things, derivable from the first by negating $b.$
If we had $ad = bc$ we would also have $a/b = c/d,$ leading to $n = b^2 (1 + (a^2 / b^2)) = d^2 (1 + (c^2 / d^2)),$ finally $b=d$ and $a=c.$ This is ruled out, so $|ad-bc| \geq 1,$ AND $ac+bd < n.$ 
SO FAR,
$$ 1 \leq ac-bd < ac + bd < n. $$ However, recall
$$    n (a^2 -  d^2) =   (ac-bd)(ac+bd).$$ Since
$$    (ac-bd)(ac+bd) \geq n$$ but
$$ n > ac+bd, $$ we find
$$    (ac-bd)(ac+bd) > ac+bd $$ and
$$ ac-bd > 1. $$
We have reached
$$ 1 < ac-bd < ac + bd < n. $$
Using  $    n (a^2 -  d^2) =   (ac-bd)(ac+bd),$ apply my LEMMA far above with $H = a^2 - d^2,$ $E = ac-bd,$ $F = ac+bd.$ The conclusion is that $g = \gcd(n, ac-bd)$ results in $1 < g < n.$ Therefore we have the nontrivial factorization $$ n = g \cdot \frac{n}{g}. $$
