Determine non-trivial homomorhisms $\phi:\mathbb{Z}_{9}\to \mathbb{Z}_{12}$ and $\phi:\mathbb{Z}_{40}\to \mathbb{Z}_{28}$ 
Determine non-trivial homomorphisms in each of the following cases:
$$(1)~ \phi:\mathbb{Z}_{15}\to \mathbb{Z}_{45},$$
$$(2) ~\phi:\mathbb{Z}_{9}\to \mathbb{Z}_{12},$$
$$(3) ~\phi:\mathbb{Z}_{40}\to \mathbb{Z}_{28}.$$

Attempt. (1) (Notation: $[a]_n:=a+n\mathbb{Z}$ for $a\in \mathbb{Z}$ and $n \in \mathbb{Z}$). Let
$$\phi_1:\mathbb{Z}_{15}\to \mathbb{Z}_{5}\times \mathbb{Z}_{3}:~[a]_{15}\mapsto ([a]_{5},[a]_3),$$
$$\phi_2:\mathbb{Z}_{5}\times \mathbb{Z}_{3}\to \mathbb{Z}_{5}\times \mathbb{Z}_9:~([a]_{5},[b]_3)\mapsto ([a]_{5},[0]_9),$$
$$\phi_3:\mathbb{Z}_{5}\times \mathbb{Z}_{9}\to \mathbb{Z}_{45}:~([a]_{5},[b]_9)\mapsto [-a+2b]_{45},$$
where $\phi_1,\,\phi_3$ are isomorphisms and $\phi_2$ is homomorphism (see the answer of Construct a non trivial homomorphism $\mathbb Z_{14} \to\mathbb Z_{21}$, noting that $-1\cdot 9+2\cdot 5=1$). Then $$\phi_3\circ \phi_2 \circ \phi_1:\mathbb{Z}_{15}\to \mathbb{Z}_{45}:[a]_{15}\mapsto [-a]_{45}$$
defines a non-trivial homomorphism, as wanted. 
Regarding the second example, since $\mathbb{Z}_9 \ncong \mathbb{Z}_3\times \mathbb{Z}_3,$ we can not proceed as above (using the   factor $\mathbb{Z}_3$). I found the same difficulty also in $\mathbb{Z}_{40}$, where $\mathbb{Z}_{40}\ncong \mathbb{Z}_4\times \mathbb{Z}_{10}$.
Thanks in advance for the help.
 A: You want group morphisms right, not ring morphisms? 
If so, I would approach the problem differently, let say that you want to establish a non trivial group morphism $\Bbb Z_a \to \Bbb Z_b$ where $a,b \in \Bbb N^*$. 
Let $k \in \Bbb Z$ such that $lcm(a,b)=ka$, and define $\phi: \Bbb Z \to \Bbb Z_b$, $n \mapsto [kn]_b$. 
Since $ker(\phi)=(b/k) \Bbb Z$, and $(b/k) | a$ then $a \Bbb Z \subset ker( \phi)$, and thus the application $\phi$ factors into a $\Bbb Z_a \to \Bbb Z_b$ map. 
It is non trivial as long as $k \neq b$ (you will have $[k]_b \neq 0$), so you just have to check that $a$ and $b$ are not coprime i.e. $gcd(a,b) \neq 1$.
Remark: $k| b$ by definition of the $lcm$, hence $(b/k)$ is an integer.
So in your cases, $a$ and $b$ are not coprime, so the following morphisms are non-trivial:
$(1)$ take $\phi: \Bbb Z_{15} \to \Bbb Z_{45}$, $[n]_{15} \mapsto [3n]_{45}$.
$(2)$ take $\phi: \Bbb Z_{9} \to \Bbb Z_{12}$, $[n]_{9} \mapsto [4n]_{12}$.
$(3)$ take $\phi: \Bbb Z_{40} \to \Bbb Z_{28}$, $[n]_{40} \mapsto [7n]_{28}$.

Edit: What about if $gcd(a,b)=1$? In that case, there is no non-trivial morphisms from $\Bbb Z_a \to \Bbb Z_b$. 
Indeed, if $\phi: \Bbb Z_a \to \Bbb Z_b$ is a group morphism, then $ker(\phi)$ is a subgroup of $\Bbb Z_a$ and $im(\phi)$ is a subgroup of $\Bbb Z_b$.
Lagrange theorem states that $card(ker(\phi)) | a$ and $card(im(\phi)) |b$.  
Moreover by the first theorem of isomorphism, $a=card(\ker(\phi)) \times card(im(\phi))$, thus $card(im(\phi)) | gcd(a,b)=1$. Hence the morphism is trivial.
