You were almost correct though. If $\displaystyle n$ is composite, we in fact have

$\displaystyle (n-1)!\ \equiv\ \left\{\begin{array}{rl} 2\mod n & \text{if}\ n=4 \\\\ 0\mod n & \text{if}\ n>4 \end{array}\right.$

If $\displaystyle n>4$ and $\displaystyle n=ab$ where $\displaystyle a,b\in\{2,3,\ldots,n-1\},$ then (i) if $\displaystyle a\ne b$ we have straightaway $\displaystyle n=ab\mid(n-1)!$ (ii) if $\displaystyle a=b$ then:

$\displaystyle a^2=n>4$

$\displaystyle \Rightarrow\ a>2$

$\displaystyle \Rightarrow\ n=a^2>2a$

$\displaystyle \Rightarrow\ a,2a\in\{2,\ldots,n-1\}$

$\displaystyle \Rightarrow\ n\mid2n=2a^2\mid(n-1)!$