Let $\mathbb{Z}_p^*$, where $p$ is prime and let $a\in\mathbb{Z}_p^*$.
Consider the following equation:$$(p-1)! \equiv (p-1)! a^{p-1} \mod p$$
I've read that since $\gcd((p-1)!, p) = 1$ we can infer that $$a^{p-1} \equiv 1$$
So I have two questions:
- Why is it true that $\gcd ((p-1)!, p)= 1$?
- Why can we infer that $a^{p-1} \equiv 1$?
The only divisors of $p$ are $p$ and $1$. What are the divisors of $(p-1)!$?
Once you know that $p, (p-1)!$ are relatively prime, consider $(p-1)! * (a^{p-1} - 1) \equiv 0 \mod p$. The relative primeness tells you that this is only possible if $(a^{p-1} - 1) \equiv 0 \mod p$