Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 3.2 Exercise 3.2.4
Let $G$ be a group. Prove that if $|G| = pq$ for some primes $p$ and $q$, then either $G$ is abelian (i.e. $Z(G) = G$) or $Z(G) = 1$.
Solution: Suppose $Z(G) \neq 1$. Since $Z(G) \leq G$, by Lagrange’s Theorem, $|Z(G)|$ divides $|G|$. Thus $|Z(G)|$ is one of $p$, $q$, or $pq$.
If $|Z(G)| = pq$, then since $G$ is finite, $G = Z(G)$ is abelian.
If (without loss of generality) $|Z(G)| = p$, then by Lagrange’s Theorem $|G/Z(G)| = q$, so that $G/Z(G)$ is cyclic. By Exercise 3.1.36, then, $G$ is abelian.