can we find all $n$ such that $p$ divides $n! - 1$? I ran into this problem while trying to solve a functional equation. I need to prove that $n=1$ and $n=p-2$ are the only solutions (for sufficiently large p)
2026-03-25 06:08:38.1774418918
On
Let p be a prime number
394 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
0
On
There is a straightforward way of producing counterexamples: If $n\ge4$ is an even number and $p$ is any prime factor of $n!-1$, then $p$ divides $n!-1$ and $1\lt n\not=p-2$ (since $n$ is even and $p-2$ is odd).
Odd numbers $n$ will also, in general, produce counterexamples, since $n!-1$ will, in general, have prime factors other than $n+2$. For example, $5!-1=119=7\cdot17$ gives the counterexample $(p,n)=(17,5)$.
Finally, since $p\mid(n!-1)$ implies $p\gt n$ (for $n\gt2$), it's clear this construction produces counterexamples with arbitrarily large primes $p$.
A totally impractical answer, but very precise. I remember, when I learned Wilson's theorem many years ago, my teacher saying "It's an impractical theorem, but useful for theoretical purposes."
For $n! \equiv 1 \pmod{p}$ we need $n < p$ (otherwise, we have $p \mid 1$). Wilson's theorem gives 2 solutions, as you stated, $1$ and $p-2$. For anything in between $$n! \equiv 1 \pmod{p} \iff (p-2)! \equiv (n+1)(n+2)...(p-2) \pmod{p} \iff\\ 1 \equiv (n+1)(n+2)...(p-2) \pmod{p}$$ or $$n! \equiv (n+1)(n+2)...(p-2) \pmod{p}$$ or $$n! \equiv (n+1)(n+2)...(p-3)(-2) \pmod{p}$$ $$n! \equiv (n+1)(n+2)...(p-4)(-3)(-2) \pmod{p}$$ $$...$$ $$n! \equiv (p-(p-n-1))...(-4)(-3)(-2) \pmod{p}$$ $$n! \equiv (-1)^{p-n-2}(p-n-1)...(4)(3)(2) \pmod{p}$$ $$n! \equiv (-1)^{p-n-2}(p-n-1)! \pmod{p}$$ or for $p>2$ $$n! \equiv (-1)^{n+1}(p-n-1)! \pmod{p}$$