For which $n$, $G$ is abelian?

My question is:

For Which natural numbers $n$, a finite group $G$ of order $n$ is an abelian group?

Obviouslyو for $n≤4$ and when $n$ is a prime number, we have $G$ is abelian. Can we consider any other restrictions or conditions for $n$ to have the above statement or the group itself should have certain structure as well? Thanks.


Solution 1:

Every group of order $n$ is abelian iff $n$ is a cubefree nilpotent number.

We say that $n$ is a nilpotent number if when we factor $n = p_1^{a_1} \cdots p_r^{a_r}$ we have $p_i^k \not \equiv 1 \bmod{p_j}$ for all $1 \leq k \leq a_i$.

(adapted from an answer by Pete Clark.)