Find the number of homomorphisms between $\mathbb{Z}_m$ and $\mathbb{Z}_n$ Although there are many attempts to the problem but I wasn't really able to understand those so I took some idea from examples and attempted it. Can someone just go through it please.
My attempt: Let $\sigma:\mathbb{Z}_{m}\to \mathbb{Z}_{n}$. The kernel $\ker(\sigma)$ is a normal subgroup of $\mathbb{Z}_{m}$. So $\ker(\sigma)=\langle\frac{m}{d}\rangle$, where $d|m$. Now $\operatorname{im}(\sigma$) is a subgroup of $\mathbb{Z}_n$. So, now the order of the image should be $d$ so $d|n$. Now the number of homomorphisms when the kernel is of order $d$ will be $\sum_{d|m,d|n}\varphi(d)$. From here we can conclude that the no of homomorphisms should be $\gcd(m,n)$. Is this OK? Where am I making mistakes?
 A: Yes, there are $\gcd(m,n)$ such homomorphisms.
Another way to see it is that we need $f([1])=[a]$ where $0\le a<n$ and that
$m[a]=[ma]=0$ in $\Bbb Z_n$, that is, $n\mid ma$ or $ma\equiv 0\pmod n$.
The solution to this congruence is $a\equiv 0\pmod{n/g}$ where
$g=\gcd(m,n)$, so that $a=jn/g$
for $0\le j<g$, so there are $g$ solutions.
A: There is an article on the same topic, of which I have a photocopy, in an old issue (sorry, don't have the date) of either American Mathematical Monthly or Mathematics Magazine (I cannot tell from my copy), authors Joseph A Gallian and James Van Buskirk.  They give the number of group homomorphisms as $\gcd(m,n)$.  Your analysis is close, except you formulated the sum incorrectly; the correct sum is over the set of divisors of the $\gcd$.  [They also give the corresponding number of ring homomorphisms.]
A: A homomorphism $\sigma:\mathbb Z_m\to\mathbb Z_n$ is uniquely determined by $\sigma(1)=a\in\mathbb Z_n$. This has to be such that $ma=\sigma(m)=0$, so that $a\gcd(m,n)=0$. Thus, there are $\gcd(m,n)$ such homomorphisms.
