Uniquely factoring a group element Exercise 7 in Rose's A Course On Group Theory reads 

Let $g\in G$ with $o(g) = n_1n_2$, where $n_1$ and $n_2$ are co-prime positive integers. Then there are elements $g_1, g_2 \in G$ such that $g = g_1g_2 = g_2g_1$ and $o(g_1) = n_1$, $o(g_2) = n_2$. Moreover, $g_1$ and $g_2$ are uniquely determined by these conditions.

I proved the first part easily enough: since $n_1$ and $n_2$ are co-prime, there exist integers $s_1$ and $s_2$ such that $n_1 s_1 + n_2 s_2 = 1$. Letting $g_1 = g^{n_2 s_2}$, $g_2 = g^{n_1 s_1}$ does the trick; one does need to know the formula $o(g^m) = o(g)/\gcd(o(g), m)$ and note that $\gcd(n_1,s_2) = \gcd(n_2, s_1) = 1$.
I'm stuck on the bolded part. If I assume $g = xy$ with $xy = yx$ and $o(x) = n_1$ and $o(y) = n_2$, how do I get $x = g_1$ and $y = g_2$?

Oh, I got it. Since $n_2s_2 = 1 - n_1s_1$ and since $x = gy^{-1} = y^{-1}g$, 
$$x = x^{1 - n_1s_1} = x^{n_2s_2} = g^{n_2 s_2}(y^{n_2})^{-s_2} = g_1.$$
Use the exponent $1 - n_2s_2$ for $y$!
