## Characterize the natural numbers which are only the orders of abelian groups

Let $n > 1$ be an integer. Prove the following classification: every group of order $n$ is abelian if and only if $n = p_1^{a_1} \cdots p_k^{a_k}$, $p_i$ are distinct primes, $a_i \in \{1,2\}$, and $p_i$ does not divide $p_j^{a_j}-1$ for all $i$ and $j$.

$(\Rightarrow)$ Suppose $n$ has the properties above; we proceed by induction on $k$.

For the base case, let $k = 1$ and let $G$ be a group of order $n = p_1^{a_1}$. Then $G$ is either cyclic or elementary abelian, hence $G$ is abelian.

For the inductive step, suppose that every group of width at most $k$ which satisfies the given conditions for $|G|$ is abelian. Let $G$ be a group of width $k+1$ such that $|G|$ satisfies the given properties. Now every proper subgroup of $G$ has width at most $k$, so that by the induction hypothesis, every proper subgroup of $G$ is abelian. By this previous exercise, $G$ is solvable.

By this previous exercise, there is a (maximal) subgroup $H \leq G$ such that $H \leq G$ is normal and $G/H$ has prime order; say $G/H \cong Z_p$. Let $P$ be a Sylow $p$-subgroup of $G$. Now by FTFGAG, $H$ is the direct product of its Sylow subgroups, and the Sylow subgroups of $H$ are normal in $H$. In particular, $H$ is generated by elements of prime and prime squared order. Let $x \in H$ have prime or prime squared order and let $y \in P$. If $\langle xy \rangle = G$, then $G$ is cyclic, hence abelian. If $\langle xy \rangle$ is a proper subgroup of $G$, then $xy = yx$, so that $\langle x \rangle \leq C_G(y)$. In either case, we have $\langle x \rangle \leq C_G(P)$. Thus $H \leq C_G(P)$, and we have $HP = G \leq C_G(P)$. Thus $P \leq Z(G)$. Similarly, $HP = G \leq C_G(H)$, so that $H \leq Z(G)$. Thus $HP = G \leq Z(G)$, and $G$ is abelian.

$(\Leftarrow)$ Suppose every group of order $n = p_1^{a_1} \cdots p_k^{a_k}$ is abelian. If (without loss of generality) $a_1 \geq 3$, let $Q$ be a nonabelian group of order $p_1^{a_1}$. (We may take $Q$ to be the direct product of a nonabelian group of order $p^3$ and a cyclic group.) Then $Q \times Z_{p_2^{a_2} \cdots p_k^{a_k}}$ is nonabelian of order $n$. Thus $a_i \in \{1,2\}$ for all $i$. Now suppose (again without loss of generality) that $p_1$ divides $p_2^{a_2} - 1$. If $a_2 = 1$, then we may construct a nonabelian group $Q$ of order $p_1p_2$. Then $Q \times Z_{p_3^{a_3} \cdots p_k^{a_k}}$ is a nonabelian group of order $n$. If $a_2 = 2$, we may construct a nonabelian group of order $pq^2$, following the patterns here or here (depending on whether $p_1$ does not or does divide $p_2-1$.) By taking the direct product with a cyclic group, there exists a nonabelian group of order $n$.

Thus, if every group of order $n$ is abelian, then $n$ has the properties enumerated in the problem statement.

If I understand correctly, you’re trying to show that $G$ must be abelian if we assume those conditions on the $p_i$ and $a_i$. We have to use the divisibility condition somewhere, since otherwise we can construct nonabelian examples.
One problem I see is that it is not a priori obvious that $P_1P_i$ is a subgroup, or even that $\langle P_1, P_i \rangle$ is a proper subgroup. If this can be shown, then I think this argument can be made to work.