## Task 4.

Determine all pairs $(p, q)$ of prime numbers for which the number

$$
p^{q+1} + q^{p+1}
$$

is a perfect square.
## Solution.

For $p=q=2$ we have $p^{q+1}+q^{p+1}=2^{3}+2^{3}=16$, so $(2,2)$ is one good pair.

Now assume that at least one of $p$ and $q$ is odd and without loss of generality let it be $p$. Let $p^{q+1}+q^{p+1}=x^{2}$, where $x \in \mathbb{N}$. $p+1$ is even, so we can write

$$
p^{q+1}=\left(x-q^{\frac{p+1}{2}}\right)\left(x+q^{\frac{p+1}{2}}\right) \text {. }
$$

Let $d$ be the greatest common divisor of the factors on the right side. If $d>1$, then $d$ must be a power of $p$ and $d$ is also a divisor of $2 x$. It is easy to see that then $p \mid q$, so $p=q$. Now we get $2 p^{p+1}=x^{2}$ which is impossible.

Therefore, $d=1, x-q^{\frac{p+1}{2}}=1, x+q^{\frac{p+1}{2}}=p^{q+1}$ and

$$
2 q^{\frac{p+1}{2}}=p^{q+1}-1
$$

The above equation cannot hold for odd $q$, because $2 q^{\frac{p+1}{2}} \equiv 2(\bmod 4)$ and $p^{q+1}-1 \equiv 0$ $(\bmod 4)$. We conclude that $q=2$ and

$$
2^{\frac{p+3}{2}}=p^{3}-1=(p-1)\left(p^{2}+p+1\right)
$$

Since $M\left(p-1, p^{2}+p+1\right)=1$ we get $p-1=1$ which is a contradiction with the assumption that $p$ is odd.

## CROATIAN MATHEMATICAL OLYMPIAD

## Second day

Zagreb, April 15, 2014.