[Math] How to calculate the total number of possible right angle triangles where the perimeter is given, and all sides are integers

number theorypythagorean triplestriangles

I have been trying to find a formula to find the number of right angled triangles where all the sides are integers and the perimeter is given. I have seen the formula x3/((1-x2)(1-x3)(1-x4)), but that gives me the amount of possible triangles with that perimeter, not the amount of right – angled triangles. Does anyone know any formulas to find the amount of right angled, integer triangles of a given perimeter? Thanks in advance!

Best Answer

To ensure the sides are integers, we use the famous parametrization: $$a=m^2-n^2$$ $$b=2mn$$ $$c=m^2+n^2$$

Then we have: ($p$ is perimeter) $$p=a+b+c=2m^2+2mn=2m(m+n)$$

When $p$ is odd, no integer solutions for $m, n$ exist.

When $p=2ab$, the number of solutions is the number of $b$ such that $a<b<2a$, which is equivalent to the number of $k$ such that $k$ is a factor of $p$ and $\sqrt{p/2}<k<\sqrt{p}$.

For even $p \le 10$, there is no solution.

The first solution occurs at $p=12$, we have $m=2, n=1$, and $(a,b,c)=(3,4,5)$.

EDIT: I realized that a solution rarely exists. If you want to find some $p$ such that a solution exists, I suggest you substitute arbitrary values of $m,n$ into the formula $p=2m(m+n)$.