0

Recently I was looking up on Wilson's theorem to find out what are the values of a function $f(n) \equiv (n-1) \pmod{n}$ for any $n$. So I know that for prime numbers $\geq $ 2 that would be -1, and it looks like for composite values $(n-1)! \equiv 0 \pmod{n} $ unless $n = 4$. So I'm wondering, why does $4$ stick out?

Bill Dubuque
  • 272,048
toxing
  • 13
  • 5

2 Answers2

2

For $n>4$ and composite, $(n-1)!\equiv0\pmod{n}$.

First suppose $n$ can be written as $n=ab$, with $a\ne b$, and both $>1$.

Then $a$ and $b$ appear as factors of $(n-1)!$, so we are done.

Otherwise $n=p^2$, for a prime $p$. Since $n>4$, we have $p\ge3$ and $(n-1)!$ contains $p$ and $2p$ as factors.

Thus the only exceptional case is $n=4$, where $3!\equiv 2\pmod{4}$.

The case $n=1$ is not exceptional either.

egreg
  • 238,574
0

If $n>4$ is composite, then either $n$ has an odd prime divisor $p$ so $p<\frac{2n}{p}<n$, or $n$ is a power of $2$, in which case $2<\frac{n}{2}<n$. In the first case $2n=p\left(\frac{2n}{p}\right)$ divides $(n-1)!$, so that $n$ divides $(n-1)!$, while in the second case $n=2\left(\frac{n}{2}\right)$ is a factor of $(n-1)!$. This does not work for $n=4$, as $2=\frac{n}{2}$.

Batominovski
  • 49,629