5. Determine all solutions $(p, n)$ of the equation

$$
n^{3}=p^{2}-p-1
$$

where $p$ is a prime number and $n$ is an integer.
Solution: The solutions of the equation are $(p, n)=(2,1)$ and $(p, n)=(37,11)$.

Rewrite the equation in the form

$$
p(p-1)=(n+1)\left(n^{2}-n+1\right) .
$$

First, observe that for any integer $n$, the value of $n^{2}-n+1$ is positive, so all factors in the rewritten equation must be positive. We have two cases.

First case: $p \mid n+1$.

For some positive integer $m$ we have $n+1=m p$ and $p-1=m\left(n^{2}-n+1\right)$. But then $n^{2}-n+1 \leq p-13$ we have $\left(m^{2}+3\right)^{2}<\Delta<\left(m^{2}+4\right)^{2}$; in the remaining cases, by direct substitution, if $m=1$ then $\Delta=8$ and if $m=2$ then $\Delta=21$.

Therefore, the solutions of the equation are $(p, n)=(2,1)$ and $(p, n)=(37,11)$.