How many Homomorphisms can be between $Z_6$ to $Z_{18}$? How many Homomorphisms can be between $Z_6$ to $Z_{18}$?
and the most important: What is the algorithm for calculating, step by step?
 A: We must know where the generator goes,
$f$ be a Homo such that $f(1)=a,f(6)=f(0)=6f(1)=6a=0$ in $Z_{18}$
so $a=3,6,9,12,15,0$
so Including trivial homo, we see there are $6$ Homomorphism 
A: Say we have a homomorphism, $\varphi:Z_n \rightarrow Z_m$. Given that $x \in Z_n$ is determined by $1_{Z_n}$, in the sense
$$
x=\underbrace{1_{Z_m}+1_{Z_m}+\cdots+1_{Z_m}}_{x \text{ times}}
$$
the properties of the homomorphism force the image to be entirely determined by the image of $1_{Z_n}$ under $\varphi$. Why? Observe, let $x \in Z_{n}$
$$
\varphi(x)=\varphi(\underbrace{1_{Z_m}+1_{Z_m}+\cdots+1_{Z_m}}_{x \text{ times}})=\underbrace{\varphi(1_{Z_n})+\varphi(1_{Z_n})+\cdots+\varphi(1_{Z_n})}_{x \text{ times}}
$$ 
All that matters is $\varphi(1_{Z_n})$, so if $1_{Z_n}$ maps to $a \in Z_{m}$ then $x\in Z_n$ must map to $xa$. Now two facts determine all the rest:
$1$. If $|x|=n$, then $|\varphi(x)|$ must divide $n$. 
$2$. Lagrange's Theorem: In any finite group, the order of a subgroup must divide the order of the group. (The converse is not true!)
The two together imply that $|a|$, the image of $\varphi(1_{Z_n})$, must divide not only $n$ (by Lagrange's Theorem) but also $m$ (by Property $1$). 
Now given we want a homomorphism $\varphi:Z_n\rightarrow Z_m$, which numbers $a$ are these? Then how many homomorphisms are there total? Finally, to see the bigger picture, what is $\text{gcd}(6,18)$? Is this a coincidence? What does this mean? 
A: A generator of $\mathbb{Z}_6$ must go to an element $z\in\mathbb{Z}_{18}$ such that $6z=0$. These elements are …
Now, given $z\in\mathbb{Z}_{18}$ such that $6z=0$, we can define a morphism $f\colon \mathbb{Z}\to\mathbb{Z}_{18}$ by $f(n)=nz$. Since $f(6n)=6nz=n(6z)=0$, the kernel of $f$ contains $6\mathbb{Z}$ and so … (apply the homomorphism theorem).
