This theorem is the converse of Wilson's theorem:
If $n$ is composite and $n>4$, then $(n-1)! \equiv 0 \pmod n$
The question holds up for all the composites I have tried but I'm struggling to form a proof for all composites greater than $4$.
This theorem is the converse of Wilson's theorem:
If $n$ is composite and $n>4$, then $(n-1)! \equiv 0 \pmod n$
The question holds up for all the composites I have tried but I'm struggling to form a proof for all composites greater than $4$.
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)!$.
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)!$.
Notice first that
Suppose $p$ is prime and $p\mid n$. Since $n$ is composite, we have $p<n$, so $p\le n-1$.
The multiplicity of the prime factor $p$ in the the factorization of $n$ is the largest integer $k$ such that $p^k\mid n$. Thus $p,p^2,p^3,\ldots,p^{k-1}$ divide $n$ and are all less than $n$. We have $$ (n-1)! = (n-1)(n-2)(n-3) \cdots 3\cdot2\cdot1. $$ The numbers $p$ and $p^{k-1}$ are both in this string of numbers from $1$ to $n-1$, so the product is divisible by $p\cdot p^{k-1} = p^k$. And $p^k$ itself is in that string of numbers unless $p^k=n$. Either way, $p^k\mid n.$
This is true of all prime numbers that divide $n$, and thus it is true of the product of those powers of primes, and the product is $n$. So $n$ is a divisor of $(n-1)!.$
Revised postscript: As Bill Dubuque points out in comments $4$ is not a divisor of $(4-1)! = 6$. The problem is this: although $p=2$ and $p^{k-1}=2^{2-1} =2 $ are both in this string of numbers, in this case $p$ and $p^{k-1}$ are both the same number, namely $p$. This happens whenever $p$ and $p^{k-1}$ are both the same number, i.e. when $p^{k-1} = p^1$ so that $k=1.$ So we can't conclude that $p\times p^{k-1}$ divides $(n-1)!$ by that same method in that case.
However, the result can be proved by another method when $k=1$ and $p>2$: Observe that $p$ and $2p$ are both divisors of $(n-1)!$, so $p^k=p^2\mid (n-1)!.$ That doesn't work when $p=2$ because in that case $2p$ is $n$ itself rather than some number less than $n$.