## Task 4.

Determine all pairs $(p, q)$ of prime natural numbers such that

$$
p\left(p^{2}-p-1\right)=q(2 q+3)
$$
## Solution.

If $p=q$, then the equation becomes $p^{2}-p-1=2 p+3$, i.e., $p^{2}-3 p-4=0$. The solutions to this equation are $p_{1}=-1$ and $p_{2}=4$, which are not prime numbers.

Assume therefore that $p \neq q$. Then $p$ divides $2 q+3$ and $q$ divides $p^{2}-p-1$. Therefore, there exists a natural number $k$ such that $2 q+3=k p$, i.e., $q=\frac{k p-3}{2}$. Substituting into the original equation, we get

$$
2 p^{2}-2 p-2=(k p-3) k, \quad \text { i.e., } \quad 2 p^{2}-\left(k^{2}+2\right) p+(3 k-2)=0
$$

If we consider the last equation as a quadratic equation in the variable $p$, we conclude that the discriminant $D=\left(k^{2}+2\right)^{2}-8(3 k-2)$ must be a perfect square.

Clearly, $D>0$, so $D>k^{4}$. In this case, it must be that $D=\left(k^{2}+1\right)^{2}$, i.e.,

$$
\left(k^{2}+2\right)^{2}-8(3 k-2)=\left(k^{2}+1\right)^{2}
$$

which gives the equation $2 k^{2}-12 k+11=0$, which has no integer solutions.

Therefore, it must be that $k<6$. By substituting the numbers $k=1,2,3,4,5$, we see that the discriminant $D$ is a perfect square only for $k=5$.

The only solution is $k=5, p=13$ and $q=31$.

## CROATIAN MATHEMATICAL OLYMPIAD

## Final selection test for the IMO team

## Zagreb, April 24, 2016.