# Existence of primitive Pythagorean triples

Let $(a,b,c)$ be a Pythagorean triple, which means $c^2=a^2+b^2$.

If $c$ is odd and $a$ & $b$ are relatively prime, then there exist integers $m$ and $n$ such that $c=m^2+n^2, ~a=m^2-n^2, ~b=2mn$.

One can easily check the above by proving $\gcd(\frac{a+c}{2},\frac{a-c}{2})=1$.

My question is whether the converse of the above also holds or not. ;Whenever the odd number $c$ is a sum of 2 squares, then there exist integers $a$ and $b$ satisfying $c^2=a^2+b^2$ and $\gcd(a,b)=1$.

Any help will be appreciated.

The odd number $45$ is a sum of two squares, but not of two relatively prime squares.

More generally, let the odd number $n$ be of the form $p_1^{2a_1}\cdots p_k^{2a_k}m$, where the $p_i$ are primes congruent to $3$ modulo $4$, and $m$ is a product of primes congruent to $1$ modulo $4$. Then $n$ is a sum of two squares, but is not the sum of two relatively prime squares.

$$\text{For any C, if } n=\frac{-1\pm \sqrt{2C-1}}{2}\text { yields an integer for }n, \text{then you have a primitive triple.}$$

$$A=2n^2+1\quad B=2n^2+2n\quad C=2n^2+2n+1 \text{ where }C-B=1$$

$$\text{If }n=\sqrt{\frac{C-1}{4}}\text{ yields an integer for n, you have a primitive triple.}$$

$$A=4n\quad B=4n^2-1\quad C=4n^2+1\quad \text{where }C-B=2$$

Otherwise $$C=m^2+n^2\Rightarrow n=\sqrt{C-m^2}\text{ where } \biggl\lceil\sqrt{\frac{C}{2}}\space\space\biggr\rceil \le m\le\bigl\lfloor\sqrt{C}\bigr\rfloor$$ For any non-integer $$n$$, that value of $$C$$ is not part of any primitive. For any integer value of $$n$$ then $$C$$ is either part of a primitive or a multiple where the multiple is either $$2$$ or a perfect square. The only way to be sure is to generate them with Euclid's formula and test the GCD.

For example; let $$C=25$$ then $$m_{min}=\lceil\sqrt{12.5}\space\rceil=4$$ and $$m_{max}=\lfloor\sqrt{25}\rfloor=5.$$ We can see that $$\sqrt{25-16}=3$$ and $$f(4,3)=(7,24,25)$$. We can also see by inspection, however that $$m=5$$ leads to a trivial solution. This only happens when $$C$$ itself is a perfect square.