<s>[INST] Prove that $\frac{a-c}{k}=\frac{d+b}{n}$, where $N=a^2+b^2=c^2+d^2$ and $k=\gcd(a-c,d-b)$, $n=\gcd(a+c, d+b)$ Let $N$ be odd and $N = a^2 + b^2 = c^2 + d^2$, where $a, b, c, d \in \mathbb{N}$ and WLOG let $a, c$ be odd, $b, d$ be even, $a > c$, and $b < d$. Prove that $\frac{a-c}{k}=\frac{d+b}{n}$.
I first began the proof my showing that $k$ and $n$ are positive integers.
Let $k= \gcd(a -c, d-b)$ and $n= \gcd(a + c, d + b)$. If $a$ and $c$ are both odd, then $a\pm c$ is even. Similarly, if $d$ and $b$ are both even, then $b\pm d$ is also even. Thus, $k$ and $n$ are also both even.
Now I wish to show that  $\frac{a-c}{k}=\frac{d+b}{n}$.
I first tried to use the fact that $N = a^2 + b^2 = c^2 + d^2$.
$$
\begin{align*}
a^2 + b^2 &= c^2 + d^2\\
a^2 -c^2 &= d^2-b^2\\
(a+c)(a-c)&=(d+b)(d-b)\\
\end{align*}
$$
This seems like I'm getting close but I can't quite see how to finish it. Any hints are appreciated.
 [/INST] It seems to me that those sums and differences are there to muddy the waters.
Let's write $A=a+c$, $C=A-c$, $D=d+b$ and $B=d-b$. As you observed, the given equation $a^2+b^2=c^2+d^2$ is equivalent to
$$AC=DB.\qquad(*)$$
And the claim is that $(*)$ implies
$$\frac C{\gcd(B,C)}=\frac{D}{\gcd(A,D)}.\qquad(\dagger)$$
It is simple to do this one prime factor at a time. So let $p$ be a prime number, and assume that in the prime factorizations we have $p^n$ appearing in $A$, $p^m$ appearing in $C$, $p^r$ in $D$ and $p^s$ in $B$. By uniqueness of factorization $(*)$ implies that
$$n+m=r+s.\qquad(**)$$
The claim $(\dagger)$ is then translated to
$$
m-\min\{m,s\}=r-\min\{r,n\}.\qquad(\dagger\dagger)
$$
This is now easy to see. From $(**)$ it follows that $m-s=r-n$. Hence $\min\{m,s\}=s$ if and only if $\min\{r,n\}=m$ in which case the claim is exactly $m-s=r-n$. In the complementary case $\min\{m,s\}=m$ and $\min\{r,n\}=r$ the claim $(\dagger\dagger)$ reads $0=0$.
</s>