What are the conditions for $n^2 \nmid(n-1)!$ 
Q: What are the conditions for $n^2 \nmid (n-1)!$, given that $2\le n \le 100$ and $n\in \mathbb{N}$?

According to me the two conditions must be:
1. $n$ is a prime number (since the factorization of $(n-1)!$ will not have a $n$ when n is prime).
2. $n = 2\times$(prime number). (Because if $p$ is the prime number such that $n=2p$, then $(2p-1)!$ will have only one $p$ in the prime factorization, but we need two.)   
Is there any other condition for $n^2\text{does not divide} ((n-1)!)$ ?   
 A: If $n$ has (at least) two distinct prime factors -- say $p$ and $q$ -- then notice that the factors $\frac{n}{p}$, $\frac{n}{q}$, $p$, and $q$ multiply to get $n^2$.  So we would like to write
$$
n^2 = \frac{n}{p} \cdot \frac{n}{q} \cdot p \cdot q \; \mid \; (n-1)!
$$
(since $p,q, \frac{n}{p}, \frac{n}{q} < n$ are contained in the expansion of $(n-1)!$.)
But a few things could go wrong:


*

*$n$ does not have at least two distinct prime factors.  Then either $n$ is a power of a prime, or $n = 1$.  If $n = 1$, in fact $n^2$ does divide $(n-1)! = 1$.  Otherwise, let $n = p^k$, $k > 0$.
1a. If $k = 1$, then this is one exception (which you list): $\boxed{n \text{ is prime}}$.
1b. If $p^{k-1} > 2k$, then we can write
$$
n^2 = p^{2k} \; \mid \; p^{p^{k-1} - 1} \; \mid \; (p)(2p)(3p)\cdots ((p^{k-1} - 1)p) \; \mid \; (n-1)!
$$
1c. Either (1a) or (1b) applies unless $(p,k) = (2,2), (2,3), (2,4), (3,2)$.  These correspond to $n = 4, 8, 16, 9$, of which $\boxed{n = 4, 8, 9}$ are genuine exceptions.

*$\frac{n}{p}$ could equal $p$ (or $\frac{n}{q}$ could equal $q$).  In this case, $n = p^2$, which is not divisible by $q$ (so this case never happens).

*$\frac{n}{p}$ could equal $q$ (or $\frac{n}{q}$ could equal $p$).  In this case, $n = pq$.  If $p,q > 2$, then we write
$$
n^2 = p^2q^2 \; \mid \; p \cdot q \cdot 2p \cdot 2q \; \mid \; (n-1)!
$$
because $p,q, 2p, 2q < pq = n$.  Otherwise, we have the exception $\boxed{n \text{ is 2 times a prime}}$.  (This exception also encompasses $n = 4$ from case 1.)
So: besides $n = 8,9$, your two conditions are correct (and you don't need the restriction $2 \le n \le 100$).
