## Task B-3.5.

Determine all prime numbers $p, q$ and natural number $r$ such that

$$
p^{2}+q^{2}+p q=r^{2}
$$
## Solution.

Obviously, $r > p$ and $r > q$. The given equation is equivalent to

$$
\begin{aligned}
(p+q)^{2}-p q & =r^{2}, \quad \text { i.e., } \\
(p+q-r)(p+q+r) & =p q
\end{aligned}
$$

Since $p$ and $q$ are primes and $p+q-r < p$ and $r > q$, we only consider the third case.

If we add the equations, we get

$$
\begin{aligned}
2 p+2 q-1 & =p q \\
2 p+2 q-p q-4+3 & =0 \\
(p-2)(q-2) & =3
\end{aligned}
$$

Thus, $p=5, q=3$ or $p=3, q=5$, and in both cases, $r=7$.

Therefore, all solutions to the equation are

$$
(p, q, r)=(5,3,7) \quad \text { or } \quad(3,5,7)
$$

## NATIONAL MATHEMATICS COMPETITION

4th grade - high school - B variant

Trogir, April 9, 2015.