A finite group is nilpotent iff two elements with relatively prime order commute (Question 9 in chapter 6.1 of Dummit and Foote). Prove that a finite group G is nilpotent if and only if whenever $a, b \in G$ with $(|a|, |b|) = 1$ then $ab = ba$. It says to use the following theorem:
Let G be a finite group, $p_1$, $p_2$, ... $p_s$ be the distinct primes dividing its order, and $P_i \in Syl_{p_i}(G)$. Then G is nilpotent iff $G \cong P_1 \times P_2 \times ... P_s$.
I believe I know the if direction: an element $a \in G$ corresponds to an element $(g_1, g_2, ... g_s) \in P_1 \times P_2 \times ... P_s$ and $|a| = lcm(|g_1|, |g_2|, ... |g_s|)$. If $b$ corresponds to $(h_1, h_2, ... h_s)$ then $(|a|, |b|) = 1$ implies each $(|g_i|, |h_i|) = 1$. Since the order of the elements divides $|P_i|$ a prime power, $|g_i|$ or $|h_i|$ has to be 1 or their gcd would not be 1. So one of every pair $g_i$ and $h_i$ has to be 1, so they commute, so $a$ and $b$ commute.
I'm not sure how to do the only if direction. Any pointers? Thank you

Here is the my proof:
I will use theorem which says: If G is finite nilpotent and $P_i$'s are Sylow-$p_i$-subgroups of G then $G= \displaystyle\prod_{p_i} P_i$ (Also this prodocut is direct but we dont need uniqueness).
Let $G$ be a nilpotent group and let $P_1$,$P_2$,..,$P_n$ be Sylow subgroups of G for every prime $p_i||G|$. Since $G$ is nilpotent we have $n_{p_i}(G)=1$ $\forall p_i$. Then $P_i$'s are normal subgroup. Since $P_i$ $\cap$ $P_j$ $=1$ for all $i \neq j$ and they are normal,  elements of $P_i$ and $P_j$ are commute (easy to check). By above theorem two elements of $G$ with relatively prime order commutes.
Conversely, suppose any two elements of $G$ with relatively prime orders are commute. Let $P_1,P_2,..P_n$ are sylow-$p_i$-subgroups of G $\forall p$ $|$ $ |G|$. So $P_i$ commutes with $P_j$  for all $i \neq j$. Then $P_i \subseteq N_G(P_j) $ for all $i \neq j$. Hence $G=N_G(P_j)$, and this implies all $P_i$'s are normal. $G$ is nilpotent.
