Proof (primary decomposition theorem)

Write $M\isom R\oplus \ldots\oplus R \oplus R/(d_1) \oplus \ldots \oplus R/(d_r)$. For each $d_i$, express it as its prime factorisation $$ \begin{align*} d_i = u\cdot p_1^{n_1} \ldots p_{k}^{n_k} \end{align*} $$ where $u$ is a unit and $p_1, \ldots, p_k$ are primes, and apply the Chinese remainder theorem $$ \begin{align*} R/(d_i) \isom R/(p_1^{n_1}) \oplus \ldots \oplus R/(p_k)^{n_k}. \end{align*} $$