How to find the number of homomorphisms of $\mathbb{Z}$ into $\mathbb{Z}$?

Consider the maps $\mu:\mathbb{Z}→\mathbb{Z}$ and $\mu:\mathbb{Z}→\mathbb{Z}_2$. For example if I am asked to find the number of homomorphisms of $\mathbb{Z}$ into $\mathbb{Z}$, and of $\mathbb{Z}$ onto $\mathbb{Z}_2$, what do I have to do? I don't have idea here. Thanks.

-
What kind of homomorphisms? Group homomorphisms and ring homomorphisms, for example, satisfy different conditions, so there are maps that are one but not the other. – Henning Makholm Dec 28 '11 at 15:54
@Junior: Presumably you meant $\mathbb{Z}_2$, not $\mathbb{Z}^2$, since you used the word "onto". Am I correct? – Zev Chonoles Dec 28 '11 at 15:55
A homomorphism $\mu: \mathbb{Z} \to G$ (where $G$ is a group) is uniquely determined by $\mu(1)$ (can you see why?). – Pedro M. Dec 28 '11 at 15:57
@Henning Makholm:group homomorphisms – Junior II Dec 28 '11 at 15:58
@Zev:yes correct – Junior II Dec 28 '11 at 16:02

This question isn't very well-posed, but luckily there's a general answer to your question. The following identities are easily verified

1) $$\text{Hom}(\mathbb{Z},\mathbb{Z})\cong\mathbb{Z}$$

2) When $n\geqslant2$ $$\text{Hom}(\mathbb{Z},\mathbb{Z}_n)\cong\mathbb{Z}_n$$

3) When $n\geqslant 2$ $$\text{Hom}(\mathbb{Z}_n,\mathbb{Z})\cong0$$

4) When $n,m\geqslant2$ $$\text{Hom}(\mathbb{Z}_n,\mathbb{Z}_m)\cong\mathbb{Z}_{(n,m)}$$

With this all in mind, and using the fact that $\text{Hom}$ and $\oplus$ (for finitely many groups) commute in both variables one can deduce that

$$\text{Hom}\left(\mathbb{Z}^r\times\mathbb{Z}_{\ell_1}\times\cdots\times\mathbb{Z}_{\ell_n},\mathbb{Z}^s\times\mathbb{Z}_{k_1}\times\cdots\times\mathbb{Z}_{k_m}\right)\cong\mathbb{Z}^{rs}\times\prod_{j=1}^{m}\mathbb{Z}_{k_j}^m\times\prod_{i=1}^{n}\prod_{j=1}^m\mathbb{Z}_{(\ell_i,k_j)}$$

Of course, this gives you a theoretical way to find the Hom group between any two finitely generated abelian groups, as well.

-

A group homomorphism $f:\mathbb{Z}\to R$ from $\mathbb{Z}$ to any commutative ring $R$ is determined by the image of $1$ since $f(n)=n f(1)$. If $f$ is required to be a ring homomorphism, we know $f(1)=1$, so there is only one homomorphism at all. This property means that $\mathbb{Z}$ is the "initial object" in the category of rings.

-
Dear rattle: I think that $$\sum_{i=1}^{-1}\ f(1)$$ is equal to $0$, not to $-f(1)$. – Pierre-Yves Gaillard Dec 28 '11 at 16:12
what to do if it is a group homomorphism? – Junior II Dec 28 '11 at 16:21
@Pierre-Yves : I believe somehow rattle meant $nf(1)$ but just didn't state his point right. – Patrick Da Silva Dec 28 '11 at 17:02
Dear @PatrickDaSilva: Thanks for your comment! It looks quite convincing to me. – Pierre-Yves Gaillard Dec 28 '11 at 17:44
You guys were right of course. Sorry for the confusion there. Fixed it. – Jesko Hüttenhain Dec 28 '11 at 20:07