TITLE: Number of Homomorphisms from $\Bbb{Z}_m$ to $\Bbb{Z}_n$
QUESTION [13 upvotes]: This question coutesy of Allan Clark's "Elements of Abstract Algebra" (60$\zeta$). 
Find the number of homomorphisms from $\Bbb{Z}_m\to \Bbb{Z}_n$ as a function of $m$ and $n$.
This is stumping me, can anyone help?

REPLY [2 votes]: I am not sure if this is the correct way to go but look good to me hence, I am sharing.
Let $f$ be the homomorphism from $\Bbb Z_{m} \to \Bbb Z_{n}$
Since $O(f([1]_{n})) \space | \space O(\Bbb Z_{n}) \implies O(f([1]_{n})) \space | \space n$
Also $O(f([1]_{n})) \space | \space m $
Hence number of homomorphism = $\gcd(n, m)$