Find all pairs of integers $(n, p)$ with $p$ prime, $0<n \leq 2 p$ and:

$$
n^{p-1} \mid (p-1)^{n} + 1
$$
Before starting the core of the exercise, it is always good to exclude some small cases. We notice that for any prime $p$, the pair $(1, p)$ is a solution. From now on, we will assume $n>1$. If $p=2$, then $n \mid 2$, so $(2,2)$ is the only solution in this case. From now on, we will assume $p$ is odd. Since $n$ is strictly greater than 1, it has a smallest prime divisor $q$.

\[
\begin{array}{ll}
(p-1)^{n} \equiv-1 & (\bmod q) \\
(p-1)^{2 n} \equiv 1 & (\bmod q)
\end{array}
\]

Thus, $\omega$ the order of $p-1$ modulo $q$ divides $2n$ and $\omega < q$, so $\omega$ is coprime with all prime divisors of $n$, hence $\omega \mid 2$.

If $\omega=1$, then $(p-1)^{1} \equiv 1(\bmod q)$, so $1 \equiv -1(\bmod q) \Longrightarrow q=2$, which is impossible because the right-hand side in the division is odd. Therefore, $\omega=2$.

Since $\omega=2$,

\[
\begin{aligned}
& (p-1)^{2} \equiv 1 \quad(\bmod q) \\
& p(p-2) \equiv 0 \quad(\bmod q)
\end{aligned}
\]

But $\omega \not \equiv 1$, so $(p-1) \not \equiv 1 \equiv q \Longrightarrow p-2 \not \equiv 0(\bmod q)$. Therefore, $q$ divides $p$, so necessarily $q=p$.

Returning to the statement, we recall that $0 < n \leq 2p$, and $n$ is a multiple of $p$, so $n=p$ or $n=2p$. If $n=2p$, then its smallest divisor is 2, and we have already treated this case. Therefore, $n=p$.

We then get $(p-1)^{p} + 1 \equiv 0(\bmod p)^{p-1}$. Expanding with the binomial theorem, we get

\[
(p-1)^{p} + 1 = p^{p} - \binom{p}{1} p^{p-1} + \ldots + \binom{p}{3} p^{3} - \binom{p}{2} p^{2} + \binom{p}{1} p - 1 + 1 \equiv p^{2} \quad\left(\bmod p^{3}\right)
\]

All terms are divisible by $p^{3}$ except possibly the last three, and $\binom{p}{2} p^{2} = \frac{p(p-1)}{2} p^{2}$ is a multiple of $p^{3}$ because $\frac{p-1}{2}$ is an integer. Conclusion: $p^{3} \nmid (p-1)^{p} + 1$ so $p-1 < 3 \Longrightarrow p=2$ or $p=3$.

The case $p=2$ has already been treated. For $p=3$, the proof that $n=p$ still holds, so $n=3$, and we find our last solution pair $(3,3)$ because $9 \mid 8+1$. Finally, the solutions to the equation are $(1, p); (2,2)$, and $(3,3)$.