# Number of homomorphisms from $\mathbb{Z}_m \to \mathbb{Z}_n$ [duplicate]

I saw this exercise:

Prove that the number of group homomorphisms from $\mathbb{Z}_m \to \mathbb{Z}_n$ is $k=\gcd(m,n)$, where $m,n$ are natural numbers. If $m,n$ are prime to each other, then the only homomorphism is the trivial one.

I know that a homomorphism $t$ from $\mathbb{Z_n}$ to some other group $H$ matches an element $g\in H$ such that $g^n = e$, $t(1)=g$. How does the $gcd$ here take place and give the number of homomorphisms?

• I added the information in the original post. I am looking for group homomorphisms. – TheNotMe Jan 18 '16 at 20:46

Hint 1: If you know $f(1)$ you know $f$. Indeed $$f(k)=kf(1) \forall k \in \mathbb Z$$
Hint 2: If $f(1)=a$ then $$0 =f(0)=f(m)=mf(1)=m a$$
Therefore $$ma \equiv 0 \pmod{n}$$
Hint 3 Show that every $a$ which satisfies Hint 2 works.
• From your hints I understand that there are $gcd(n,m)$ elements s.t. $ma = 0 (mod n)$ where $a \in \mathbb{Z_n}$? – TheNotMe Jan 18 '16 at 20:39
• @TheNotMe Let $d=\gcd(m,n)$, and $m=dm_1, n=dn_1$. Then $n|ma \Leftrightarrow n_1|m_1a \Leftrightarrow n_1|a$. Now write $a=kn_1$, how many choices do you have for $k$ ? ;) – N. S. Jan 18 '16 at 20:47