Solution (source code)

= Solution

Let $T$ be the set of <torsion elements> of the given <Abelian group>. It contains the <identity element>, which has order one. If $g,h\in T$ have orders $m,n$, set $\ell=\operatorname{lcm}(m,n)$. Commutativity permits powers of the product to split:
$$
(gh^{-1})^\ell=g^\ell h^{-\ell}=e.
$$
Hence $gh^{-1}$ has finite order, dividing $\ell$, and lies in $T$. The nonempty set $T$ therefore satisfies the <subgroup test> and is a <subgroup>:
$$
\boxed{T=\{g\in G:\operatorname{ord}(g)<\infty\}\leq G.}
$$
This is the <torsion subgroup>. The proof uses commutativity exactly when rearranging the factors in $(gh^{-1})^\ell$; one cannot use that step in an arbitrary noncommutative <group>. The subgroup need not itself be a finite set.