6. Fermat's Little Theorem and Wilson's Theorem
Lemma: Suppose that $(a,m)=1$, then the least residues of $ka$ for $k=1, \ldots, m-1$ are a permutation of $0,1, \ldots, m-1$. Proof) There are $m-1$ numbers in $\mathbb{Z}/m\mathbb{Z}$ that is not congruent to $0$. Let $ka$ and $k'a$ be two numbers with $1 \leq k, k' \leq m-1$, then we have $(k-k')a \equiv 0$ implies that $(k-k') \equiv 0$ as $(a, m)=1$, however because $-m < k-k' < m$, we see that $k=k'$. Hence there cannot be two different $k, k'$ with different least residue. Thoerem (Fermat's Little Theorem): If $p$ is prime and $(a,p)=1$, then $a^{p-1} \equiv 1 ~(\bmod{~p})$ Proof) Given any $p$, a prime, we know that $(a,p) = 1$. Hence $a, 2a, \ldots, (p-1)a$ all have different least residues which would be $1, \ldots, p-1$. If we multiply them together, $(p-1)! \equiv a^{p-1}(p-1)!$ as $(a, l) = 1$ for $l=1, \ldots, p-1$, we may conclude that $a^{p-1} \equiv 1~(\bmod{~p})$. Easy application of Fermat's Little Theorem would be, Cor...