# Factorials and the Mod function

I was just playing with the factorial and the modulo function. I just observed this interesting property. I was using a calculator

$$13!\equiv 13\times 12\pmod{169}\\ 17!\equiv 17\times 16\pmod{289}$$

It is easily verifiable that this works for $2,3,5,7,11$ also.

I conjecture that for any prime $p$, $$p!\equiv (p)\times (p-1)\pmod{p^2}$$

How does one go about proving it? and by the way is this well known or anything?

## 1 Answer

By Wilson's Theorem we have $(p-1)!\equiv -1\equiv p-1\pmod{p}$. Your conjectured result is obtained by multiplying through by $p$.

• How do you prove that the last operation is valid.(The one where you multiply everything by $p$). Apr 3 '16 at 3:30
• Oh! It follows from the definition of the congruent modulo function. +1 Apr 3 '16 at 3:34
• Yes, it is very close to Wilson's Theorem. We have $p(p-1)!-p(p-1)$ is divisible by $p^2$ if and only if $(p-1)!-(p-1)$ is divisible by $p$. Apr 3 '16 at 3:42
• By the way, Leibniz was the first person to state the result that would later be called Wilson's Theorem. It is not known whether he had a proof. For sure Wilson did not! The first known proof is by Lagrange. Apr 3 '16 at 3:48