# How to calculate $\frac{1}{p - 1} \mod p$?

I'm trying to use Wilson's theorem to simplify $(p - 2)! \mod p$, for a prime $p$. From the theorem it follows that it is equivalent to $\frac{1}{p - 1} \mod p$, but this isn't an integer so I'm not too sure what to do with it.

Is my deduction incorrect? Or am I just missing how to calculate the modulos of a fraction?

• $p-1\equiv -1\pmod p$ so...
– lulu
Oct 20 '16 at 15:30

## 4 Answers

By definition, $1/b\pmod{p}$ means the multiplicative inverse of $b$ in $\Bbb Z/(p)$. That is, $1/b$ is the element $u$ of $\Bbb Z/(p)$ such that $bu\equiv 1\pmod{p}$. In your case, you need to find an element $u$ such that $u(p-1)\equiv 1\pmod{p}$. But $p-1\equiv -1\pmod{p}$, so $u$ must be...

The value $\frac{1}{p-1}$ is probably more intuitive when written as $(p-1)^{-1}$, i.e. the number with which $p-1$ must be multiplied to obtain $1 \mod p$.

To simplify even further, note that $p-1 \equiv -1 \mod p$. What does this imply about the inverse of $p-1$?

I think you're overcomplicating things: $(p-1)!\equiv -1$ (mod $p$) by Wilson's theorem, and $p-1\equiv -1$ (mod $p$), so multiplying both sides by $-1$ we get $(p-2)!\equiv 1$ (mod $p$).

$\frac{1}{p-1}\equiv x\pmod p$ so $x(p-1)\equiv 1 \pmod p$ so
$-x\equiv 1\pmod p$ so $x\equiv -1\pmod p$