To begin with, I have seen other solutions of the following question in similar threads but I didn't see any such solution. If there is and I didn't notice it I am sorry.
Question: Let $G$ be a finite abelian group written as $$G=C_{d_1}\times\dots C_{d_k}$$ where $1\neq d_1|d_2|\dots|d_k$ (I believe the $d_i$s are called invariants of $G$) where $C_{d_i}$ denotes the cyclic group of order $d_i$. Prove that $G$ cannot be generated by less than $k$ elements.
My attempt: Let $p$ be a prime dividing $d_1$. Therefore each $C_{d_i}$ contains an element of order $p$ and $G$ contains $p^k-1$ distinct elements of order $p$. Let's say that $G$ were generated by $j$ elements, $j<k$. By the fact that $G$ is the image of a free abelian group of dimension $j$, I can write $G$ as $$G=C_{m_1}\times\dots C_{m_j}$$. An element of the last product has the form $(a_1,\dots,a_j)$ and its order is the least common multiple of the orders of the $a_i$. Therefore there can be only $p^j-1$ elements of order $p$ contradicting the initial statement.
Is my solution correct?