Classifying abelian numbers I am stuck on this problem from Dummit and Foote (exercise 5.5.24).

Let $n$ be an integer $> 1$. Prove the following classification: every group of order $n$ is abelian if and only if $n=p_1^{\alpha_1}p_2^{\alpha_2}...p_r^{\alpha_r}$, where $p_1,...,p_r$ are distinct primes, $\alpha_i=1$ or $2$ for all $i\in\{1,...,r\}$ and $p_i$ does not divide $p_j^{\alpha_j}-1$ for all $I$ and $j$. [See Exercise 56 in section 4.5]

Now exercise 56 (and the ones preceding it) were a series of exercises classifying all "cyclic numbers" ie. numbers $n$ such that if $G$ is a group of order $n$, then $G$ is necessarily cyclic. The subsequent result was very similar to this, and exercise 56 yielded the additional result that every finite group in which all proper subgroups are abelian is solvable (and not simple).
Considering how these exercises worked I assume I need to work with an inductive argument, though I am not sure how to execute it. I also imagine I might need to construct a normal subgroup $H$ and its complement $K$ (Sylow theorems?) to work with their semi-direct product $H\rtimes_{\varphi} K$ and show that the only possible homomorphism $\varphi: K\to \operatorname{Aut}(H)$ defining this product is trivial. I haven't succeeded in implementing any of these ideas thus far. Any hint in the right direction would be of great help.
 A: Okay, so in comments you say that you already know the "only if" clause. Let's discuss the "if" clause.
Assume the result holds for any group of order strictly smaller than $|G|$ satisfying the given conditions. In particular, since every subgroup and quotient of $G$ has order satisfying the given conditions, any proper subgroup of $G$ and any proper quotient of $G$ is abelian.
Note that the result follows easily if $r=1$. If $r=2$, then the Sylow $p_i$-subgroups are normal (the number of them must divide $p_j^{\alpha}$ for the other $j$, and be congruent to $1$ modulo $p_i$, which can only happen if the number is $1$ since $p_i$ doe snot divide $p_j^{\alpha}-1$). And so $G$ is the direct product of two abelian groups, hence abelian. So we may assume that $r\geq 3$.
By the referenced problem 56 of section 4.5, it follows that $G$ is solvable, since every proper subgroup of $G$ is abelian.
Consider $[G,G]$, which is a proper subgroup of $G$ (and hence abelian).
I claim first that $[G,G]$ is a $p$-group. Indeed, if this is not the case then we can write $[G,G]=A\times B$, with $A$ and $B$ nontrivial and of relatively prime orders. But then $A$ and $B$ are characteristic in $[G,G]$, and hence normal in $G$. Then $G/A$ is abelian (since it is a proper quotient of $G$), contradicting the fact that $[G,G]$ is the smallest normal subgroup of $G$ such that the quotient is abelian. Thus, $[G,G]$ is a $p$-group. Let $P$ be a Sylow subgroup of $G$ that contains $[G,G]$; say it is the $p_i$-subgroup. Note that because it contains $[G,G]$, it is normal.
If $p_j\neq p_i$, and $P_j$ is a Sylow $p_j$-subgroup of $G$, then $[G,G]P_j$ is an abelian normal subgroup of $G$ (subgroup because $[G,G]$ is normal, normal because any subgroup containing $[G,G]$ is normal, abelian because it is a proper subgroup of $G$ since $r\geq 3$). Since $P_j$ is characteristic in $[G,G]P_j$, because $\gcd(|[G,G]|,|P_j|)=1$, it is normal in $G$. But that means that the Sylow $p_j$-subgroup of $G$ is normal for any $p_j\neq p_i$, and we already knew the Sylow $p_i$-subgroup is normal. Thus,
$G=P_1\times\cdots\times P_r$, where $P_i$ is the Sylow $p_i$-subgroup of $G$. Since each $P_i$ is of order $p_i$ or $p_i^2$, it is abelian. Hence $G$ is abelian, as claimed.
