For which numbers $n$ is every group of order $n$ nilpotent?
Solution 1:
The characterization of such numbers has been known for a while, see for example "Nilpotent numbers" by Pakianathan and Shankar.
Here is the characterization. Write the prime factorization of $n$ as $n = p_1^{k_1} \cdots p_t^{k_t}$.
Then every group of order $n$ is nilpotent if and only if $p_i^s \not\equiv 1 \mod{p_j}$ for all $i \neq j$ and $1 \leq s \leq k_i$.
Here is an explanation why the condition is necessary:
If $p_i^s \equiv 1 \mod{p_j}$ for $1 \leq s \leq k_i$, then $p_j$ divides the order of $\operatorname{Aut}((\mathbb{Z}/p_i\mathbb{Z})^s) \cong \operatorname{GL}_s(\mathbb{Z}/p_i\mathbb{Z})$. Thus we can form a nontrivial semidirect product $H = (\mathbb{Z}/p_i\mathbb{Z})^s \rtimes \mathbb{Z}/p_j\mathbb{Z}$. Because $H$ is non-abelian and its Sylow subgroups are abelian, it follows that $H$ is not nilpotent. Then $$H \times (\mathbb{Z}/p_i\mathbb{Z})^{k_i - s} \times (\mathbb{Z}/p_j\mathbb{Z})^{k_j - 1} \times \mathbb{Z} / m \mathbb{Z}$$ for $m = n/{p_i^{k_i} p_j^{k_j}}$ is a non-nilpotent group of order $n$.
Related questions have been asked many times, see here, here, here and here..