<s>[INST] How many special right triangles are there? We all learned in school about "special" right triangles. Special right triangles have integer side lengths. Examples include the $3$-$4$-$5$ right triangle, the $5$-$12$-$13$ right triangle, the $8$-$15$-$17$ right triangle, and their scalar multiples ($6$-$8$-$10$, $10$-$24$-$26$, $16$-$30$-$34$, etc).
How many are there? Is there a limit to the number of lowest-form (no scalar multiple) special right triangles? Are there any patterns that arise from the progression of integer side lengths?
 [/INST] This goes back to Diophantus.
Let $a,b,c$ be positive integers such that $a^2+b^2=c^2$. Then $(a,b,c)$ is a Pythagorean triple. If $p$ is a prime common divisor of $a$ and $b$, then $p$ also divides $c$: if $a=pA$ and $b=pB$, then $c^2=p^2(A^2+B^2)$, so that $p$ divides $c^2$, hence $c$. Similarly, if $a$ and $c$ have a common prime divisor, this prime divides also $b$. Thus we can assume that $a$ and $b$ are coprime, by factoring out all prime common divisors. Such a triple is primitive.
Next we can show that $a$ and $b$ are of different parity: one is odd and the other is even. They can't be both even, because they are coprime. If they were both odd, we could write $a=2A+1$ and $b=2B+1$, so
$$
a^2+b^2=4(A^2+A+B^2+B)+2=c^2.
$$
This is impossible, because $c$ must be even, so $c=2C$ and we'd get
$$
2=4(A^2+A+B^2+B-C^2
$$
which is clearly impossible.
Assume, without loss of generality, that $a$ is odd and $b$ is even. Then we can write $b=2B$ and
$$
B^2=\frac{c+a}{2}\frac{c-a}{2}.
$$
Let $p$ be a prime dividing both $(c+a)/2$ and $(c-a)/2$. Then $p$ divides the sum, which is $c$, and the difference, which is $a$: absurd. Therefore $(c+a)/2$ and $(c-a)/2$ are coprime. Since their product is a square, both must be squares.
Thus
$$
\frac{c+a}{2}=u^2,\quad\frac{c-a}{2}=v^2
$$
from which we derive
$$
a=u^2-v^2,\quad b=2uv,\quad c=u^2+v^2.
$$
Moreover $u$ and $v$ are coprime; they can't be both odd, because otherwise $a$ would be even.
Conversely, any pair $(u,v)$ of coprime positive integers, one odd and the other even, with $u>v$, gives rise to a primitive Pythagorean triple.
For $u=2$, $v=1$ we get the triple $(3,4,5)$; for $u=3$, $v=2$ we get the next one $(5,12,13)$ and so on.
</s>