Confusion in proving $\phi: Z_n \to Z_k$ defined by $\phi (x)=x \mod k$ to be a homomorphism. 
It is to be proven that if $k|n$ and $\phi: Z_n \to Z_k$ is defined by
$\phi (x)=x\mod k $, then $\phi$ is a homomorphism.


$\phi$ is well defined as: $x=y\implies x\mod k=y \mod k$ 
To prove that $\phi$ is operation preserving, let $x,y \in Z_n$, it is possible that $x+y \notin Z_n$ so we consider 
$\phi ((x+y) \mod n)=((x+y)\mod n)\mod k \tag{1}$ 
I got stuck here. I want to show that $\phi ((x+y) \mod n)=\phi(x)+\phi (y) \tag{2}$.
The problem is that since in general, $(x+y) \mod n \mod k \ne (x+y) \mod k \mod n$ and also $(x+y) \mod n=(x\mod n+ y\mod n) \mod n$, I don't know how to show that $(1)$ implies $(2)$.
Thanks for your time.
 A: My suggestion is to convert the $\rm mod$ notation into a more transparent form.
An element $x \in \mathbb{Z}_n$ is an equivalence class $[x]_n$ of integers of the form $x+an$ for $a \in \mathbb{Z}$.
The homomorphism $\phi: \mathbb{Z}_n \to \mathbb{Z}_k$ is defined as $x \mapsto [x]_k$. To show that it is well defined, you need to show that $\phi(a)=\phi(b)$ whenever $a,b$ are congruent ${\rm mod} n$. To show that it is a homomorphism, you need to show that $\phi(0)=0$, and that $\phi(x+y)=\phi(x)+\phi(y)$.
Now, the key hypothesis is that $k$ divides $n$: write $n=kj$ for some $j \in \mathbb{Z}$. Then:
$$x+an = x+ajk = x+bk$$
so in particular if you take any $y \in [x]_n$ then $y \in [x]_k$ as well, which shows that $\phi$ does not depend on the representative that you choose in $[x]_n$ (in other words: it is well defined).
Now: $$\phi(x+y) = [x+an+y+bn]_k = [x+y]_k$$
and
$$\phi(x)+\phi(y) = [x+an]_k + [y+bn]_k = [x]_k + [y]_k = [x+y]_k$$
A: If you have a homomorphism $\phi\colon\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/k\mathbb{Z}$, you can compose it with the canonical projection $\pi\colon\mathbb{Z}\to\mathbb{Z}/n\mathbb{Z}$ and get a homomorphism $\phi\circ\pi\colon\mathbb{Z}\to\mathbb{Z}/k\mathbb{Z}$ whose kernel contains $n\mathbb{Z}$.
Conversely, given $\psi\colon\mathbb{Z}\to\mathbb{Z}/k\mathbb{Z}$ whose kernel contains $n\mathbb{Z}$, you get a unique homomorphism $\bar{\psi}\colon\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/k\mathbb{Z}$ such that $\psi=\bar{\psi}\circ\pi$ (homomorphism theorems).
It's easier to manage homomorphism with domain $\mathbb{Z}$, because they're determined by the image of $1$, which can be an arbitrary element of the codomain.
Now you basically want that the homomorphism $\psi\colon\mathbb{Z}/n\mathbb{Z}\to\mathbb{Z}/k\mathbb{Z}$ defined by $\psi(x)=x+k\mathbb{Z}$ (that is, $\psi(1)=1+k\mathbb{Z}$) satisfies $n\mathbb{Z}\subseteq\ker\psi$.
When does this hold? Precisely if and only if $n\in\ker\psi$, which means $n\in k\mathbb{Z}$. Therefore your $\phi$ is a well defined map (if it is, it certainly is a homomorphism) if and only if $k$ divides $n$.
Thus it's clear why you get stuck: you cannot prove in general that the map is well-defined to begin with, unless you assume that $k\mid n$.
Just by way of example, suppose $n=3$ and $k=4$. Since $3(1+3\mathbb{Z})=0+\mathbb{Z}$, you'd need $3(1+4\mathbb{Z})=0+4\mathbb{Z}$, which is clearly false.
