How Many Homomorphisms $\Bbb{Z}_4 \to \Bbb{Z}_8 \times \Bbb{Z}_{12} \times \Bbb{Z}_{15}$? I know that the number of homomorphisms between $Z_n$ and $Z_m$ is $\gcd(m,n)$. However, I don't know what to do with these two questions:

  
*
  
*How many different homomorphisms exist: $\Bbb{Z}_4 \to \Bbb{Z}_8 \times \Bbb{Z}_{12} \times \Bbb{Z}_{15}$
  
*How many different homomorphisms exist: $\Bbb{Z}_2 \times \Bbb{Z}_2 \to \Bbb{Z}_8 \times \Bbb{Z}$
  

Any tips?
 A: A homomorphism into a direct product is essentially the same as a collection of homomorphisms (one for each factor). Similarly, a homomorphism from a direct product is the same as a collection of homomorphisms, one from each factor. (To be precise: We are talking of products with finitely many factors here).
So for 1. check: How many homomorphsims are there $\mathbb Z_4\to\mathbb Z_8$? $\mathbb Z_4\to\mathbb Z_{12}$? $\mathbb Z_4\to\mathbb Z_{15}$? 
And for 2. check: How many homomorphisms are there $\mathbb Z_2\times\mathbb Z_2\to \mathbb Z_8$? (You may count the homomorphisms $\mathbb Z_2\to\mathbb Z_8$) first). And how many homomorphisms are there $\mathbb Z_2\times\mathbb Z_2\to \mathbb Z$? (You may count the homomorphisms $\mathbb Z_2\to\mathbb Z$) first). 
A: Disclaimer: This solution is most probably overkill.
Dealing with abelian groups, we are right in the context of homological algebra. One of the main characters in homological algebra is the functor ${\rm Hom}(A,-):\mathbf{Ab}\to\mathbf{Ab}$ assigning to an abelian group $B$ the abelian group ${\rm Hom}(A,B)$ of group homomorphisms $A\to B$ and it's contravariant counterpart ${\rm Hom}(-,B):\mathbf{Ab}\to\mathbf{Ab}$ assigning to an abelian group $A$ the group ${\rm Hom}(A,B)$. Two of the first properties we can prove are
$$
{\rm Hom}\left(A, \prod_{i\in I} B_i\right) \cong \prod_{i\in I} {\rm Hom}(A,B_i),
$$
$$
{\rm Hom}\left(\bigoplus_{i\in I} A_i, B\right) \cong \prod_{i\in I} {\rm Hom}(A_i,B).
$$
(Note that for finite products $\bigoplus$ and $\prod$ are isomorphic.)
This is the fact Hagen von Eitzen mentioned, when he said, that a homomorphism into a product is a familiy of homomorphisms into each factor and a homomorphism from a product is a family of homomorphisms from each factor. Together with the classification theorem for finitely generated abelian groups, this boils all the ${\rm Hom}$-groups between those down to the following:
\begin{align*}
{\rm Hom}(\ \mathbb Z\ ,\ \mathbb Z\ )&\cong \mathbb Z,\\
{\rm Hom}(\ \mathbb Z\ , \mathbb Z_n)&\cong \mathbb Z_n,\\
{\rm Hom}(\mathbb Z_n,\ \mathbb Z\ )&\cong 0,\\
{\rm Hom}(\mathbb Z_n, \mathbb Z_m)&\cong \mathbb Z_d \quad\text{where $d=\gcd(n,m)$}.
\end{align*}
Proving these is essentially what you are doing in your exercise in the general case.
Together you come up with
\begin{align*}{\rm Hom}(\mathbb Z_4, \mathbb Z_8 \times \mathbb Z_{12} \times \mathbb Z_{15})
&\cong
{\rm Hom}(\mathbb Z_4, \mathbb Z_8) \times {\rm Hom}(\mathbb Z_4, \mathbb Z_{12}) \times {\rm Hom}(\mathbb Z_4, \mathbb Z_{15})
\\&\cong \mathbb Z_4 \times \mathbb Z_4 \times \mathbb Z_1 \cong \mathbb Z_4 \times \mathbb Z_4,
\\
{\rm Hom}(\mathbb Z_2 \times\mathbb Z_2, \mathbb Z_8 \times\mathbb Z)
&\cong
{\rm Hom}(\mathbb Z_2 \times\mathbb Z_2, \mathbb Z_8) \times\underbrace{{\rm Hom}(\mathbb Z_2 \times\mathbb Z_2, \mathbb Z)}_0
\\&\cong {\rm Hom}(\mathbb Z_2, \mathbb Z_8) \times {\rm Hom}(\mathbb Z_2, \mathbb Z_8) \cong \mathbb Z_2 \times \mathbb Z_2.
\end{align*}
Thus the answers to your questions are $16$ and $4$.
