Task 5. Determine all pairs of prime numbers $(p, q)$ such that $p^{2}+5 p q+4 q^{2}$ is the square of an integer.
Solution. Write $p^{2}+5 p q+4 q^{2}=a^{2}$, with $a \geq 0$ an integer. The left side is equal to $(p+2 q)^{2}+p q$, so we can rewrite this as $p q=a^{2}-(p+2 q)^{2}$, or $p q=(a-p-2 q)(a+p+2 q)$. The second factor on the right is greater than $p$ and greater than $q$, but it is a divisor of $p q$. Since $p$ and $q$ are prime, it must be equal to $p q$, so $a+p+2 q=p q$. And then $a-p-2 q=1$. Subtract these two: $p q-1=(a+p+2 q)-(a-p-2 q)=2(p+2 q)$, or $p q-2 p-4 q-1=0$. This can be rewritten as $(p-4)(q-2)=9$. The factor $q-2$ cannot be negative, so $p-4$ cannot be negative either. The factors must therefore be equal to 1 and 9 or 9 and 1 or 3 and 3. This gives for $(p, q)$ the possibilities $(5,11),(13,3)$ and $(7,5)$. Checking shows that $p^{2}+5 p q+4 q^{2}$ is a square in each of these cases, namely $28^{2}, 20^{2}$ and $18^{2}$. So these three pairs are the solutions.