Decomposition of finitely-generated abelian group To formulate the question I need to remind two theorems in algebra:


*

*Any finitely generated abelian group $G$ is isomorphic to a direct sum of cyclic groups:


$$
G\simeq\mathbb Z_{u_{1}} \oplus \dots \oplus \mathbb Z_{u_{m}}\oplus \mathbb Z\oplus \dots \oplus \mathbb Z\qquad (1)
$$ 
where $u_{i}|u_{i+1}$.
Every finite term of this decomposition can be also decomposed to a direct sum of primary cyclic groups. So we can say that every finitely generated abelian group $G$ is isomorphic to a direct sum of primary cyclic groups and infinite cyclic groups.


*

*All the Sylow subgroups of a finite group are normal if and only if the group is isomorphic to the direct product of its Sylow subgroups.


So, if $|G|=p_{1}^{n_{1}}\cdots p_{k}^{n_{k}}$ and all Sylow $p_{i}$-subgroups $P_{1}$, ..., $P_{k}$ are normal, then 
$$G\simeq P_{1}\times\cdots \times P_{k}\qquad (2)$$
So here is the question:
Let the group $G$ satisfy the conditions of both theorems at the same time. Then we will have two decompositions $(1)$ and $(2)$. Is there some correspondence or relationship between these decompositions? (I mean maybe they are isomorphic or it's the same or something else). Can you explain this to me?
 A: See the Wikipedia article on finitely-generated abelian groups for more information. We have
Theorem A. Any finite abelian group $G$ admits a unique invariant factor decomposition.
Theorem B. Any finite abelian group $G$ admits a unique primary decomposition.
These decompositions are different, but logically Thm A $\Leftrightarrow$ Thm B: that is, once you prove one, the other follows from Sun-Ze (aka CRT), ${\bf Z}/nm\cong {\bf Z}/n\times{\bf Z}/m$ when $(n,m)=1$. Further one can compute one decomposition from the other (+ vice-versa). Let's discuss how.
Suppose we have the invariant factor decomposition of $G$ from Thm A as follows:
$$G\cong \frac{\bf Z}{n_1}\times\frac{\bf Z}{n_2}\times\cdots\times\frac{\bf Z}{n_l}.$$
Then each $n_i$ factors as $\prod_pp^{e(i,p)}$ for primes $p$ and exponents $e(i,p)$. By SZ then
$$G\cong\prod_{i=1}^l\frac{\bf Z}{n_l}\cong\prod_{i=1}^l\prod_p\frac{\bf Z}{p^{e(i,p)}}\cong\prod_p\left[\prod_{i=1}^l\frac{\bf Z}{p^{e(i,p)}}\right].$$
Notice the factors $\prod_{i=1}^l{\bf Z}/p^{e(i,p)}$ are $p$-groups; this is the primary decomposition, which is the same as the Sylow decomposition (as a direct product of Sylow $p$-subgroups, available for all nilpotent groups) when our group is abelian. It is probably best to think of Sylow theory as the inevitable noncommutative generalization of arithmetic in the theory of finitely-generated abelian groups.
Our original hypothesis that we had the invariant factor decomposition means that $n_i\mid n_{i+1}$, so we must have $e(i,p)\le e(i+1,p)$ for each $p$. Also, some of the $e$'s may be $0$. Thus if we begin with a primary decomposition as regarded in Thm B, we may order the prime exponents in an increasing order, and fill in extra $0$s as needed so that each prime has the same number of exponents, then form the $n_i$ out of the prime powers created from these exponents.
Here's an example. From a primary decomposition we obtain
$$\begin{array}{llccccc} G & \cong & \left(\frac{\bf Z}{2} \times \frac{\bf Z}{2}\times\frac{\bf Z}{8}\right) & \times & \left(\frac{\bf Z}{3}\times\frac{\bf Z}{27}\right) & \times & \left(\frac{\bf Z}{5}\right) \\ & \cong & \left(\color{Magenta}{\frac{\bf Z}{2}} \times \color{Blue}{\frac{\bf Z}{2}} \times \color{Green}{\frac{\bf Z}{8}} \right) & \times & \left(\color{Magenta}{\frac{\bf Z}{1}} \times \color{Blue}{\frac{\bf Z}{3}} \times \color{Green}{\frac{\bf Z}{27}} \right) & \times & \left(\color{Magenta}{\frac{\bf Z}{1}} \times \color{Blue}{\frac{\bf Z}{1}} \times \color{Green}{\frac{\bf Z}{5}} \right) \\ & \cong & \left(\color{Magenta}{\frac{\bf Z}{2}\times\frac{\bf Z}{1}\times\frac{\bf Z}{1}} \right) & \times & \left( \color{Blue}{\frac{\bf Z}{2}\times\frac{\bf Z}{3}\times\frac{\bf Z}{1}} \right) & \times & \left( \color{Green}{\frac{\bf Z}{8}\times\frac{\bf Z}{27}\times\frac{\bf Z}{5}} \right) \\ & \cong & \frac{\bf Z}{2\times1\times1} & \times & \frac{\bf Z}{2\times3\times1} & \times & \frac{\bf Z}{8\times27\times5} \\[7pt]  & \cong & {\bf Z}/2 & \times & {\bf Z}/6 & \times & {\bf Z}/1080 \end{array}$$
as our invariant factor decomposition, with $2\mid6\mid1080$. And to see how to go in reverse with this same example, just read from bottom to top.
In conclusion, then, there are two standard fundamental representations of a finite abelian group, the invariant-factor decomposition and the primary decomposition. Theorems A and B state their existence and uniqueness; these are roughly logically equivalent using the remainder theorem, and it is relatively easy to move between the two decompositions using prime factorization. The IF representation invokes linear algebra, the primary decomposition invokes group theory (it is positioned within Sylow theory), and they are both positioned within commutative algebra.
A: Well the two standard decompositions for a finitely generated abelian group (or more generally modules over a PID) are invariant factor decomposition and elementary divisor decomposition. The invariant factor decomposition is the first one you give, and the elementary divisor decomposition is $G = \mathbb Z/p_1^{k_1} \times ... \times \mathbb Z/p_n^{k_n}$, where $p_i$ are not necessarily distinct primes. Clearly you can group these to get the sylow-p groups. 
Since these are the same group they must be equivalent, but to actually show either of them exist the most convenient method is use of the Chinese Remainder Theorem. Mainly that $\mathbb Z/m \times \mathbb Z/n$ = $\mathbb Z/mn$ if $(m,n)=1$. This allows you to break the $a_i$'s you gave (generally referred to as invariant factors) into their prime components, or given a decomposition into a direct sum of $\mathbb Z/p_i^{k_i}$'s (generally $p_i^{k_i}$ is referred to as an elementary divisor you can combine them easily to create some $a_i's$. 
If you know a bit of module and ring theory you can use the CRT to prove the Fundamental Theorem of Abelian Groups yourself. As any finitely generated $\mathbb Z$ module $G$ is $ (\times_{i=1}^n \mathbb Z)/M $, where $M$ is some submodule of the finite direct product of $\mathbb Z's$. Now you can show that $M= \times_{i=1}^nI_i$ where $I_i$ is an ideal of $\mathbb Z$ so equal to $(r_i)$ for some $r_i \in \mathbb Z$. So we can then conclude $G= \times_{i=1}^n \mathbb Z/(r_i)$, and use the CRT as above to conclude that we can find either form giiven above (i.e. for elementary divisors use the CRT to break up  $r_i$ into its  prime divisors).
If this did not stick you can see any decent graduate algebra text and look up modules over PIDs to see this more thoroughly examined.
