I am pretty sure that it has been already discussed many times, but I couldn't find.
Well, the problem is to show that $\mathrm{Hom}(\mathbb Z/n\mathbb Z, \mathbb Z/m\mathbb Z)\simeq\mathbb Z/(n,m)\mathbb Z$.
I have proven that $Hom(Z/nZ, Z/mZ)$ is precisely $Ann(nZ) = \{x \in Z/mZ: nx = 0\}. $ Thus my problem reduces to proving $Ann(nZ) = Z/(n,m)Z$, but I haven't gotten success so far.
We have $$ \operatorname{Hom}_{\mathbb{Z}}\left ( \mathbb{Z}/n\mathbb{Z},\mathbb{Z}/m\mathbb{Z} \right )\cong \mathbb{Z}/n\mathbb{Z}\otimes_{\mathbb{Z}}\mathbb{Z}/m\mathbb{Z}\cong \mathbb{Z}/\left ( n,m \right )\mathbb{Z}, $$ see here, and here.