-1

Prove $(n-1)! = -1 \ (\textrm{mod n})$ iff n is prime

I can understand how the first part of the proof $(n-1)!=-1 \ (\textrm{mod n})$ is true if n is prime simply by testing it out. However, I'm unsure of how to go about proving it.

2 Answers2

1

Notice $(n-1)! = 1 \cdot 2 \cdot 3 \cdot \cdots \cdot n-1$ and, ignoring $1$, each number on that list has a distinct (why?) multiplicative inverse (why?) on that list except ...

... $-1 \cong n-1$ because it is its own inverse.

Eric Towers
  • 67,037
  • Why $n-1$ is the only one with this property? I mean, why the others elements have distinct inverses? –  Nov 08 '19 at 15:44
  • 1
    Suppose $p$ is a prime and $1< k = k^{-1} \pmod{p}$, then $k^2 = mp+1$ for some $m \in \Bbb{Z}$, giving $(k-1)(k+1) = mp$. Since $0<k-1<k+1<p$ and $p$ is prime, neither $k-1$ not $k+1$ divides $p$, so $(k-1)(k+1) \neq mp$. – Eric Towers Nov 08 '19 at 15:48
  • Thank you very much! –  Nov 08 '19 at 15:51
0

Hint: If $n$ is prime then $\mathbb{Z}_n$ is a group i.e every element has an inverse. Also, if we know $n$ isprime (assume $>2$) then $n$ is odd. You have;

$$(n-1)! = (n-1)(n-2)(n-3) \cdots 3 \cdot 2$$

The union of all the elements above is $\mathbb{Z}_n$.