3. A right-angled triangle has integer lengths of sides. Its perimeter is the square of a natural number. We also know that one of its legs has a length equal to the square of a prime number. Determine all possible values of this length.

(Patrik Bak)
SOLUTION. We are looking for all prime numbers $p$ for which there exists a described triangle with one leg of length $p^{2}$. Let the length of its other leg be $b$ and the length of the hypotenuse $c$. Then, according to the Pythagorean theorem, the equation $c^{2}=p^{4}+b^{2}$ holds, which we rearrange into a product form

$$
p^{4}=c^{2}-b^{2}=(c+b)(c-b) .
$$

Since $c>b>0$ (the hypotenuse is longer than the leg), the right side of (1) is the product of two natural numbers $c+b$ and $c-b$, with $c+b>c-b$. The number $p^{4}$ on the left side of (1), however, can be factored into the product of two different natural numbers in exactly two ways (when the larger factor is written first): $p^{4} \cdot 1$ and $p^{3} \cdot p$. Thus the sum $c+b$ is equal to either $p^{4}$ or $p^{3}$. In the first case, the perimeter $o=p^{2}+b+c$ of our triangle has the value $o=p^{2}+p^{4}$, in the second case it is $o=p^{2}+p^{3}$.

According to the problem, the perimeter is a square of a natural number. If the value $p^{2}+p^{4}=p^{2}\left(p^{2}+1\right)$ were such, then with regard to the factor $p^{2}$, the factor $p^{2}+1$ one greater would also have to be a square, which is clearly impossible - it is a number $2 p$ less than the square $(p+1)^{2}$, which follows the square $p^{2}$.*

Therefore, the second case must occur, when the value $o=p^{2}+p^{3}=$ $=p^{2}(p+1)$ is a square. This happens precisely when the factor $p+1$ is a square, which, as we will immediately show, is satisfied by only one prime number $p=3$. Indeed, from the equality $p+1=k^{2}$ for integer $k>1$ we have $p=(k-1)(k+1)$, given that $\mathrm{k} 0$ are coprime natural numbers. Now from the equalities

$$
2 p^{2}=\left(c+p^{2}\right)-\left(c-p^{2}\right)=d u^{2}-d v^{2}=d\left(u^{2}-v^{2}\right)
$$

we see that $d$ is a divisor of the number $2 p^{2}$, which is at the same time less than $p^{2}$, since certainly $u^{2}-v^{2}>2$. We thus necessarily have $d \in\{1,2, p, 2 p\}$. These values can be individually evaluated by substituting into the equality[^1]$2 p^{2}=d(u+v)(u-v)$. From this, we then determine the factors $u+v$ and $u-v \cdot *$ We will write this here only for the value $d=2 p$ (which is the only one that does not lead to a contradiction): For it we get $(u+v)(u-v)=p$, so $u-v=1$ and $u+v=p$. When the resulting values of $u$, $v$ are substituted together $\mathrm{s} d=2 p$ into the formula $o=d u(u+v)$, we get after rearrangement $o=p^{2}(p+1)$ and the process can be easily completed as in the original solution.

For a complete solution, award 6 points. In incomplete solutions, evaluate partial steps as follows.

A1. Derivation of equation (1) (in product form!): 1 point.

A2. Derivation of the conclusion that $b+c \in\left\{p^{4}, p^{3}\right\}: 1$ point.

A3. Exclusion of the case $b+c=p^{4}$ : 1 point.

A4. Derivation that in the case $b+c=p^{3}$ it holds $p=3: 2$ points.

A5. Verification that the value $p=3$ (even if guessed) satisfies: 1 point.

B1. Derivation of the equation $b^{2}=\left(c+p^{2}\right)\left(c-p^{2}\right): 0$ points.

B2. Observation that the greatest common divisor of the factors $c+p^{2}, c-p^{2}$ (from equation in B1) is a divisor of the number $2 p^{2}$, i.e., one of the values $1,2, p, 2 p, p^{2}, 2 p^{2}: 1$ point.

B3. Exclusion of the values 1, 2, p, $p^{2}, 2 p^{2}$ from point B2: 3 points

B4. Solving the case with the value $2 p$ from point B2 (including verification): 2 points

In total, then award $\max (\mathrm{A} 1+\mathrm{A} 2+\mathrm{A} 3+\mathrm{A} 4+\mathrm{A} 5, \mathrm{~B} 2+\mathrm{B} 3+\mathrm{B} 4)$ points.

A solution that does not contain the required conclusion that the only possible length of the tangent leg is 9, can be rated no higher than 5 points.[^2]

[^0]:    * The solution can also be concluded without mentioning the isosceles trapezoid: According to the common axis of segments $A E$ and $G H$, the segments $H A$ and $G E$ are symmetrically conjugate, and thus congruent.

[^1]:    * The obvious statement that two consecutive natural numbers cannot both be squares does not need to be proven by solvers in their protocols.

    ** Verification of these two properties of $v$ in the mentioned process is not necessary: we have the equality from the Pythagorean theorem guaranteed and we know that the perimeter $p^{2}(p+1)$ is a square, because there is such a number $p+1=4$.

[^2]:    * For the values $d=1$ and $d=2$, we will use the fact that due to the coprimality of the numbers $u$, $v$, the numbers $u+v, u-v$ can have only one common divisor greater than 1, namely the number 2.