Is this sufficient criterion for existence of non-abelian groups also necessary? In the formula section of Sloane's integer sequence A060652 - Orders of non-Abelian groups , we find

Let the prime factorization of $n$ be $p_1^{e_1}\cdots p_r^{e_r}$. Then $n$ is in this sequence if $e_i>2$ for some $i$ or $p_i^k \equiv 1 \pmod {p_j}$ for some $i$ and $j$ and $1 \le k \le e_i$.

While the formulation only says "if", not explicitly "if and only if", it better be listed as the formula only if it actually is an "if and only if". But is it?
Note that the "if" part is clear: Whenever the criterion holds, we can take direct product with a non-abelian factor  $Z_p^2\rtimes Z_p$  or $\Bbb F_{q^k}\rtimes Z_p$ where $p$ divides $|\Bbb F_{q^k}^\times |$. But as $PSL_2(7)\not\cong (\Bbb F_8\rtimes Z_7)\times Z_3$ shows, not all non-abelian groups are obtained in this way this argument suggests (even though $168$ does fit the criterion). 
 A: I figured I'd post an answer.
Let $n=p_1^{e_1}\cdots p_r^{e_r}$ be an integer, such that 


*

*Every $e_i\le2$ 

*$p_i^k\neq1\pmod{p_j}$ for $1\le k\le e_i$. 


We want to show every group of this order is abelian.
We can assume that this is not true, and let $n$ be the smallest counterexample (that is, we're assuming there exists a non-abelian group $G$ of order $n$). Note that all divisors of $n$ satisfy the condition in the previous paragraph, and so all proper subgroups of $G$ are abelian.
Note first that every Sylow subgroup is abelian (really by condition 1).
If every Sylow subgroup of $G$ is normal, then $G$ is the direct product of these Sylow subgroups, and so $G$ is abelian.  Thus, we can assume there's a Sylow subgroup $P\le G$ that is not normal.
Thus $N_G(P)<G$, and by minimality, $N_G(P)$ is abelian.  Thus $P\le Z(N_G(P))$, and so (by the Burnside Transfer Theorem) $G$ has a normal subgroup $K$ such that $G=K\rtimes P$. Since $K$ is proper, it is abelian, and in particular, is a direct product of its (abelian) Sylow subgroups.
How does $P$ act on a Sylow subgroup of $K$? By condition $2$, it has to act trivially.  Thus $G$ is really $K\times P$, which is abelian.
