How to find all Pythagorean triples containing a given number?

Hint: There are no integer right triangles with a hypotenuse of 12 (why?), so the side of length $12$ must be a leg, and then $144 = c^2-b^2 = (c+b)(c-b)$.


Let a Pythagorean triple be of the form $(x,y,z)$ where one of $x, y$ or $z$ is 12. From Elementary Number Theory we know that $z$ is odd, and $x \not\equiv y \pmod{2}$ (i.e. one of $x$ and $y$ is odd and one is even). (I will omit the proof of this but it is fairly simple). We also know that for primitive Pythagorean triples: $$x=2pq, \\ y=p^2-q^2 \\ z=p^2+q^2\\$$ for some $p>q>0$.

We therefore know that 12 must be $x$ as $x$ is even, so we look at all the factors of $6$ to find the possible values for $p,q$.

$$ 6 = 6 \cdot 1=2 \cdot 3 $$

So our possible values for $p$ are: $p=6$ or $p=3$, and our possible values for $q$ are: $q=1$ and $q=2$.

With $p=6,q=1$ we get: $x=12,y=35,z=37$ and $P=x+y+z=84$.

With $p=3,q=2$ we get: $x=12,y=5,z=13$ and $P=30$.

So the maximal perimeter corresponds to the triangle with sides $12, 35, 37$ and perimeter $84$.

---EDIT---

The above only considered primitive Pythagorean triples. To consider all P.ts we must look at those where all numbers are less than 12 and find the non primitive triples which arise from them. These are:

$$(4,3,5) \rightarrow (12,9,15),(16,12,20) $$ Upon multiplying by $3$ and $4$ respectively.

Neither of these triples give rise to a perimeter greater than $84$, so the triangle with one side of length $12$ with greatest perimeter is the triangle corresponding to $(12,35,37)$