First we prove by contradiction that for any primitive Pythagorean triplet ##(x, y, z)## (##z^2## being the sum on RHS), exactly one of either ##x, y## must be odd, while the other must be even.
- If both ##x, y## are even, then the RHS ##z^2## would also be even, in turn implying that ##z## is also even. This in turn implies that 2 is a common divisor of ##x, y, z##, contradicting the requirement of primitiveness.
- If both of ##x, y## are odd, they can be written as ##x=(4a + r_1), y=(4b + r_2)## for some positive integers ##a, b## such that ##r_1 = x \mod 4, r_2 = y \mod 4## and ##r_1, r_2 \in \{1, 3\}##. Then the Pythagorean sum becomes ##z^2 = 4a^2 + 8ar_1 + r_{1}^{2} + 4b^2 + 8br_2 + r_{2}^{2} \\
\Rightarrow z^2 \mod{4} \equiv (r_1^2 + r_2^2) \mod{4} \equiv 2 \mod{4}##. This implies that ##z^2## is even but not a multiple of 4. But this would mean that there can be no integer solution for ##z## since an odd ##z## cannot given an even ##^2## and an even ##z## will mean ##z^2 \equiv 0 \mod{4}##, again a contradiction.
Hence the only possibility is that one of ##x,y## is odd and the other is even. This implies ##z^ = x^2 + y^2## is odd and hence ##z## too must be odd.
Proof for the if part:
Given ##u, v## are coprime with ##u > v## and exactly one of them is odd. Let ##x = u^2 - v^2, y = 2uv, z = u^2 + v^2##. ##x^2 + y^2 = (u^4 + v^4 - 2u^2v^2) + 4u^2v^2 = (u^4 + v^4 + 2u^2v^2) = (u^2 + v^2)^2##
##\Rightarrow x^2 + y^2 = z^2##. Thus ##x, y, z## form a Pythagorean triplet. To prove that it is a primitive triplet, let us assume that on the contrary ##x, y## have some common prime divisor ##p##.
##p \mid x \Rightarrow p \mid x^2 \Rightarrow p \mid (u - v)(u + v)##.
(Eq.1)
Note that ##p## cannot be 2 since ##x## is odd. Thus ##p \mid y \Rightarrow p \mid 2uv \Rightarrow uv##
##\Rightarrow p \mid u## or ##p \mid v##
(Eq. 2)
Since ##u, v## are coprime, we may assume without loss of generality in
(Eq. 2) that ##p \mid u##. But this contradicts
(Eq. 1) since both ##(u-v)## and ##(u+v)## must be coprime w.r.t. ##u## and hence neither of them can have ##p## as their divisor. Thus the assumption of there being a common prime divisor for ##x,y## must be wrong and hence the triplet must be primitive.
Proof for the only if part:
Suppose ##(x, y, z)## is a primitive Pythagorean triplet with ##x^2 + y^2 = z^2##. We already proved that any such triplet must have an odd ##z## and exactly one odd number on LHS. Without loss of generality, let us assume that ##x## is the odd number on LHS (and so ##y## must be even). Since both ##x## and ##z## are odd and ##z > x##, we may rewrite them as ##x = (a - b), z = (a+b)## where ##a, b## are positive integers given by ##a = \dfrac {x + z} {2}## and ##b = \dfrac {z - x} {2}##.
(Eq. 3)
Thus ##y^2 = z^2 - x^2 \Rightarrow (a+b)^2 - (a-b)^2 = 4ab \Rightarrow y = 2 \sqrt {ab}##.
(Eq. 4)
Since ##y## is an integer, ##ab## must be a perfect square.
(Eq. 5)
##a, b## must be coprime since otherwise ##ab##, ##(a-b)## and ##(a+b)## will have some common prime divisor ##p## which would contradict the initial assumption that ##(x, y, z)## have no common divisor. This condition together with
(Eq. 5) implies that ##a## and ##b## must themselves be perfect squares coprime w.r.t. each other. Thus we may write ##a=u^2, b=v^2## for some coprime integers ##u, v## with ##u > v##. Substituting for ##a, b## in
(Eq. 3) and
(Eq. 4) we get ##x = u^2 - v^2, z = u^2 + v^2## and ##y = 2 \sqrt {u^2 v^2} = 2uv##. Hence proved.