Let $G,H,$ and $K$ be finite abelian groups. If $G \times H \cong G\times K$ then $H\cong K$.
I am trying to use the fundamental theorem for abelian groups to solve this, it is clear intuitively that I can decompose $G \times H$ and $G \times K$ and then cancel out the factors of $G$ but I have no clue on writing this rigorously, or if my method is right.
Edit: Can I say that $H \cong \Bbb{Z}_{p^i} \times \ldots \times \Bbb{Z}_{p^n}$ and $K \cong \Bbb{Z}_{p^q} \times \ldots \times \Bbb{Z}_{p^k}$ and since $G \times H \cong G\times K$ then $G\times \Bbb{Z}_{p^i} \times \ldots \times \Bbb{Z}_{p^n} \cong G \times \Bbb{Z}_{p^q} \times \ldots \times \Bbb{Z}_{p^k}$ , but the representation is unique hence $\Bbb{Z}_{p^i} \times \ldots \times \Bbb{Z}_{p^n} \cong \Bbb{Z}_{p^q} \times \ldots \times \Bbb{Z}_{p^k}$ that is $H \cong K$?