# Every finitely generated module of a PID is a direct sum of a free module and of a torsion module

Let $$R$$ be a PID. Show that every finitely generated $$R$$-module is a direct sum of a torsion module and of a free module.

Attempt:

There's a theorem that claims that if $$M$$ is a finitely generated $$R$$-module (where $$R$$ is a PID) then $$\exists R^\times\ni a_1|\dots|a_k\ne0, r>0$$ s.t. $$M\cong R ^r\oplus\bigoplus_{i=1}^k R/\langle a_i\rangle$$

$$R^r$$ is obviously a free module. We want to show that $$N:=\bigoplus_{i=1}^k R/\langle a_i\rangle$$ is a torsion moodule: Let $$A_i:=\langle a_i\rangle$$. Let $$N\ni n=(r_1+A_1,\dots,r_k+A_k)$$.

IF we find $$\forall 1\leq i\leq k$$ some $$l_i\in R$$ s.t. $$r_il_i\in A_i$$ then we finish the proof (because $$n\cdot l_1\cdots l_k=0_N\Rightarrow n\in\operatorname{Tor}(N))$$.

Let $$1\leq i\leq k$$. Let $$r:=r_i, A:=A_i$$ and $$a:=a_i$$. We want to find $$l,t\in R$$ s.t $$lr=at$$. I'm not sure how.