Constructing a basis for finite abelian groups Let $G$ be a finite abelian group, and $g_1, \ldots, g_k$ a set of "linearly independent elements", namely such that $\langle g_1 \rangle \oplus \ldots \oplus\langle g_k \rangle$.
I would like to "complete" this set to a basis for $G$. Of course this can not be done literally, so what I am really after is a procedure to
1) substitute $g_1, \ldots, g_k$ with elements $h_1, \ldots, h_k$ such that $g_i$ is a suitable multiple of $h_i$,
2) add further elements $h_{n-k+1}, \ldots, h_n$
such that $\langle h_1\rangle \oplus \ldots \oplus\langle h_n\rangle=G$.
If the cardinality of a minimal set of linearly independent generators for $G$ is $a$, and the cardinality of a maximal set of linearly independent generators for $G$ is $b$, what can we say about $n$? (besides the fact that $a \leq n \leq b$)? What is the minimal $n$ that realizes our request?
I am pretty sure this must simple and well-known, so I would be happy with a reference.
 A: By the classification of finite abelian groups, $G$ is the direct sum of cyclic groups of prime power order. The maximal number of generators is one per summand in this decomposition. The minimal number is obtained by combining relatively prime summands, i..e it is the maximal number of summands for a given prime.
More formally:
$$\tag{1}G\cong\bigoplus_{p \mathrm{\ prime}}\bigoplus_{n \in \mathbb N}\left(\mathbb Z/p^n\mathbb Z\right)^{e_{p,n}}$$
with $e_{p,n}\in\mathbb N_0$ and allmost all $e_{p,n}=0$.
Then one can write $G\cong\langle g_1\rangle\oplus\ldots\langle g_r\rangle$ with nontrivial elements $g_1,\ldots,g_r$ iff 
$$\max_p\sum_n e_{p,n}\le r\le\sum_{p,n}e_{p,n}.$$
More precisely: The maximal number $b$ of generators on the right hand side is achieved if one take one generator from each direct summand in (1) (recall that the exponentiation with $e_{p,n}$ stands for repeated summands). 
The minimal number $a$ of generators on the left is achieved if one groups the summands in (1) by primes (which is the reason why I structered the sum like this in the first place) and then to for each generator takes one summand from each prime (as long as there are any left). This uses the fact that the direct sum of cyclic groups of coprime order is again cyclic.
If $n$ is any integer with $a\le n\le b$, then it is possible to write $G$ with $n$ linearly independent generators. To see this note that a minimal set of generators was obtained from a maximal one by combinig relatively prime summands. If you don't combine these all at once but rather step by step, you will have $n$ generators at some step while going from $b$ down to $a$.
But can this step also be achieved by the procedure described in your question post?
Yes, it can.
In order to increase the number of generators by one, select one of the generators $g_i$ that does not have prime power order; such $g_i$ exists because otherwise the generator set would be maximal. Then the order of $g_i$ can be written as $r\cdot s$ with $r,s>1$ and coprime. Then $\langle g_i\rangle=\langle r\cdot g_i\rangle\oplus\langle s\cdot g_i\rangle$ and we have increased the number of generators by replacing one with two multiples of itself.
A: From the classification of finitely generated abelian groups, we know that a finite abelian group is isomorphic to a product (or a direct sum, those are the same for abelian groups) :
$\bigoplus_{0<i\leq k}\mathbb{Z}/d_i\mathbb{Z}$ where the $d_i$'s are either powers of prime numbers or numbers each a multiple of the one before (ie $d_1\vert d_2\vert ...\vert d_k$). In either case, the $d_i's$ are completely determined by $G$ (up to order for the powers of prime numbers).
Regarding the minimal and maximal values for the number of independant generators, I'd say $k$ is minimal, if we take the $d_i$'s dividing each other, and maximal if we take the "prime" decomposition, although I am not sure of it.
A good exposition of this fact can be found in many basic books dealing with commutative algebra, for instance, the Atiyah-McDonald.
A: It is not possible to do such a thing, see the example provided to my question in 
https://mathoverflow.net/questions/107768/on-the-existence-of-a-direct-summand-containing-a-fixed-subgroup,
or also 
Smallest pure subgroup containing a fixed subgroup
