
Problem 8.3 Find all pairs of prime numbers $p$ and $q$, such that $p^{2}+3 p q+q^{2}$ is:

a) a perfect square;

b) a power of 5 .


Solution: a) Let $p^{2}+3 p q+q^{2}=r^{2}$, where $p$ and $q$ are prime numbers. If $p \neq 3, q \neq 3$, then $p^{2}+3 p q+q^{2} \equiv 2(\bmod 3)$ and $r^{2} \equiv 2(\bmod 3)$, a contradiction. Without loss of generality $p=3$ and we get that $q^{2}+9 q+9=r^{2}$ and $4 q^{2}+36 q+36=(2 r)^{2}$. Therefore $(2 q-2 r+9)(2 q+2 r+9)=45$. We may assume that $r>0$ and so $2 q+2 r+9=15$ or $2 q+2 r+9=45$. In the first case $q+r=3$, which is impossible and in the second case solving the system

$$
\left\lvert\, \begin{array}{cc}
q+r & =18 \\
2 q-2 r+9 & =1
\end{array}\right.
$$

we find $q=7$. Because of the symmetry the only solutions are $p=$ $3, q=7$ and $p=7, q=3$.

b) Let $p^{2}+3 p q+q^{2}=5^{n}$, where $n$ is a natural number. Since $p \geq 2, q \geq 2$, we have $p^{2}+3 p q+q^{2} \geq 20$ and so $n \geq 2$. It follows now that $25 /\left(p^{2}+3 p q+q^{2}\right)$ and $5 /\left(p^{2}+3 p q+q^{2}\right)=(p-q)^{2}+5 p q$. Thus, $5 /(p-q)^{2}$ and $25 /(p-q)^{2}$. Therefore $25 / 5 p q$, showing that $p=5$ or $q=5$. But if $p=5$ then $q=5$ (and vice versa). We obtain $p^{2}+3 p q+q^{2}=125=5^{3}$. The only solution of the problem is $p=q=5$.
