Equation involving Wilson's theorem Find all primes $p$ such that
$$(p-1)!=p^k-1.$$
Where $k$ is a natural number.

this is a pretty known one:
for $p=2$, we have $2^k-1=1$ which gives $k=1$.
for $p=3$, we have $3^k-1=2$ which also gives $k=1$.
for $p=5$, we have $5^k-1=4!=24$ which gives $k=2$.
For $p>5$:
note that $p-1|(p-2)!$ for every prime $p>5$. Why?
Because $p-1=2\frac{p-1}{2}$ and given that $2$, and $\frac{p-1}{2}$ are smaller than $p-2$, not equal to each other and that the second one is integer (i.e. $p$ is odd), we can find both of them in $(p-2)!$ expansion.
If $2 \geq p-2$ then $p \leq 4$ so $p=2$ or $3$, contradiction. Similarly, if $\frac{p-1}{2}=p-2$ then $p=3$ and when $\frac{p-1}{2}=p-2$ then $p=5$, both contradicting $p>5$. Also,$p$ is even since $p>5>2$.
Therefore, $(p-1)^2|(p-1)!$ so $(p-1)^2|p^k-1=(p-1)(1+p+ \ldots +p^{k-1})$.
Therefore, $p-1|1+p+ \ldots +p^{k-1} \equiv 1+1+ \ldots +1 \equiv k \pmod{p-1}$.
Therefore, $p-1|k$.
This gives $p^{p-1}-1| \leq p^k-1=(p-1)!$ which after some routine gives $p=2$.
Indeed, after substitution, $(2,1),(3,1),(5,2)$ are the only solution pairs.
