Prove that if $n$ is composite, then $(n-1)! \equiv 0 \pmod n$ [duplicate]

Solution 1:

If $n$ is composite, then there are $1<a<b<n$ with $ab=n$, unless $n=p^2$ is the square of a prime. In the first case, $a$ and $b$ appear in the product $(n-1)!$ thus $n|(n-1)!$. In the second case, your hypothesis $n>4$ implies $p\geq 3$ and thus $1<p<2p<n-1$ so that $2n=p\times 2p$ divides $(n-1)!$.

Solution 2:

Suppose first that there exist integers $a$ and $b$, such that $1\lt a\lt b\le n-1$ and $ab=n$. Then since $b\le n-1$, it follows that $ab$ divides $(n-1)!$. For each of $a$ and $b$ appears among the numbers from $1$ to $n-1$.

But $n$ can be composite without meeting the above condition: It could be that the only proper factorizations of $n$ have the shape $n=a^2$. (This only happens if $a$ is prime.) In that case, if $a\ne 2$, then $a$ and $2a$ are both $\le n-1$. So $2a^2$ divides $(n-1)!$, and therefore $a^2$ divides $(n-1)!$.

Solution 3:

If $n=pq$, try to prove that $pq$ divides $(n-1)!$