5. Determine all natural numbers $n$ and prime numbers $p$ for which $p^{2}+7^{n}$ is a perfect square.

## Third grade - B category
5. Let's denote $p^{2}+7^{n}=m^{2}$ for some $m \in \mathbb{N}$. The squares of integers, when divided by 3, can only give remainders of 0 and 1; if $p \neq 3$, then $p^{2}$ would give a remainder of 1 when divided by 3, and since $7^{n}$ also gives a remainder of 1 when divided by 3 (because 7 gives a remainder of 1 when divided by 3), the left side would give a remainder of 2 when divided by 3, and thus could not be equal to $m^{2}$. Therefore, the only possibility is $p=3$. Then we have $7^{n}=m^{2}-3^{2}=(m-3)(m+3)$. For $m-3=1$, we get $m=4$ and $n=1$, which is a solution. Now assume $m-3>1$. Then it follows that $m-3=7^{a}$ and $m+3=7^{b}$ for some $a, b>1$, and by subtracting we get $7^{b}-7^{a}=6$; however, this is impossible because the left side is divisible by 7 while the right side is not.

Therefore, the only solution to the problem is $p=3$ and $n=1$.

## Third Grade - B Category