4. Problem: Find all triples $(x, p, n)$ of non-negative integers such that $p$ is prime and
$$
2 x(x+5)=p^{n}+3(x-1) \text {. }
$$
Solution: The equation rearranges to be
$$
p^{n}=2 x(x+5)-3(x-1)=2 x^{2}+7 x+3=(2 x+1)(x+3) \text {. }
$$

Since $x$ is a non-negative integer, both factors $(2 x+1)$ and $(x+3)$ must be positive integers. Therefore both $(2 x+1)$ and $(x+3)$ are both powers of $p$. Let
$$
\begin{aligned}
2 x+1 & =p^{a} \\
x+3 & =p^{b} .
\end{aligned}
$$

Now note that $\operatorname{gcd}(2 x+1, x+3)=\operatorname{gcd}(x-2, x+3)=\operatorname{gcd}(5, x+3)$ which must equal either 1 or 5 (because 5 is prime). We consider each case individually:
- If $\operatorname{gcd}(2 x+1, x+3)=5$ then $p=5$ and $\min (a, b)=1$. Thus either $2 x+1=5$ or $x+3=5$. Either way we get $x=2$. This leads to $p^{n}=25$ and so $(x, p, n)=(2,5,2)$.
- If $\operatorname{gcd}(2 x+1, x+3)=1$ then $\min (a, b)=0$. Thus $2 x+1=1$ or $x+3=1$. So either $x=0$ or $x=-2$. We can't have $x<0$ so we must have $x=0$. This leads to $p^{n}=3$ and so $(x, p, n)=(0,3,1)$.

Therefore the only solutions for $(x, p, n)$ are $(2,5,2)$ and $(0,3,1)$.