Let $R$ be a principal ideal domain and $M$ be an finitely generated $R$-module.
The torsion module $M_{\text{tors}}$ is defined as $$ M_{\text{tors}} := \left\{ m \in M \;|\; \text{there is}\; a\in R \setminus \{0\} \;\text{with}\; am = 0 \right\}. $$
I want to show that there is a $R$-submodule $M' \subset M$ with $M = M' \oplus M_{\text{tors}}$.
What I tried: I know that
$$ M \cong R^r \oplus R/(a_1) \oplus \cdots \oplus R/(a_s), $$
for some $r \in \mathbb{N}_0$ and $a_1, \dots a_s \in R \setminus \{0\}$.
It is also clear that $R/(a_i)$ are fields, since $(a_i)$ is maximal because we are in a principal ideal domain.
However, I don't know how to show that $R^r \cong M_\text{tors}$.