Write the composite numberas n=ab, with 2≤a≤b<n. If a<b, both a and b occur as distinct factors of the factorial(n−1)!, so their product n divides that factorial.
If a=b, then n=a2 and n>4 implies a≥3. Both a and 2a are distinct factors in (n−1)!, because 2a≤a2−1. Their product is 2n, so again n divides the factorial. Hence
The exception n=4matters: its factorial3!=6 is not divisible by 4. This argument handles perfect squares without incorrectly counting the same factor twice.