TITLE: Computing $\mathrm{Hom}(\mathbb Z_n,\mathbb Z_m)$ as $\mathbb Z$-module
QUESTION [22 upvotes]: My algebra is weak I need help computing $\mathrm{Hom}(\mathbb Z_n,\mathbb Z)$, $\mathrm{Hom}(\mathbb Z_n,\mathbb Z_m)$ and also $\mathrm{Hom}(\mathbb Z,\mathbb Z)$ as $\mathbb Z$-modules. Also books suggestion to improve my basic. Thank you.
Regards

REPLY [16 votes]: $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$ consists of module-homomorphisms $$\phi: \mathbb{Z}\rightarrow \mathbb{Z}$$ So, for instance the module-homomorphism $\epsilon(x)=0$ (the module-homomorphism sending everything to $0$), and $\iota(x)=x$ (the module-homomorphism sending everything to itself) are all inside $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$. But $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$ is not just a set of module-homomorphisms, it is also a $\mathbb{Z}$-module. This is because if we have two homomorphisms $\phi, \psi\in\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$ we can add them and make a new module-homomorphism by: $$(\phi+\psi)(z)=\phi(z)+\psi(z)$$ Similarly for an integer $n\in\mathbb{Z}$, $n\phi(z)$ is also a module-homomorphism. This shows that $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$ is a $\mathbb{Z}$-module. Now to your question:
To find out what $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$ looks like, let us see if we can find out what all of the module-homomorphisms look like. If $\phi\in\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})$, then we only have to specify what $\phi(1)$ is, because then $\phi(a)=a\phi(1)$ we know what this particular module-homomorphisms look like for all values of $a\in\mathbb{Z}$. So let $\phi(1)=n$, for which value of $n$ is this a module-homomorphism? Well, every value works! Since $\phi(a+b)=an+bn=\phi(a)+\phi(b)$, and $r\phi(a)=ran=\phi(ra)$. Since every value of $n\in\mathbb{Z}$ works, we must have $$\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},\mathbb{Z})\cong\mathbb{Z}$$
Let us look at $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z}_n,\mathbb{Z})$ using the same approach: 
Let $\phi\in\operatorname{Hom}(\mathbb{Z}_n,\mathbb{Z})$, and let $\phi(1)=a$ for $a\in\mathbb{Z}$. We know that $\phi(0)=0$ so $\phi(0)=\phi(n)=na=0$ what can you say about $a$?
$\operatorname{Hom}_\mathbb{Z}(\mathbb{Z}_n,\mathbb{Z}_m)$ is a little bit trickier, but still uses all of the same ideas: let $\phi\in\operatorname{Hom}_\mathbb{Z}(\mathbb{Z}_n,\mathbb{Z}_m)$, and let $\phi(1)=a$ for $a\in\mathbb{Z}_n$. We know (again) that $\phi(0)=0$, so $\phi(n)=\phi(0)=n\phi(1)=na=0$. But this time $na\equiv_m 0$. So $m$ divides $an$ and $an=mk$ for some integer $k$. 
Let $d=\gcd(m,n)$ then $a(n'd)=(m'd)k\Rightarrow an'=m'k\Rightarrow a=\frac{m'k}{n'}$. This needs to be an integer so we need to choose $k$ such that this happens. Since $\gcd(m',n')=1$ we must have that $k$ is a multiple of $n'$, that is $$k\in\{n',2n',3n',\dots, dn'\}$$ Thus there are $d=\gcd(m,n)$ choices for $k$ and therefore $$\operatorname{Hom}_\mathbb{Z}(\mathbb{Z}_m,\mathbb{Z}_n)\cong \mathbb{Z}_d$$