What are all the homomorphisms between the rings $\mathbb{Z}_{18}$ and $\mathbb{Z}_{15}$?

If one has a homomorphism of two rings $R, S$, and $R~$ has an identity, then the identity must be mapped to an idempotent element of $S$, because the equation $x^2=x$ is preserved under homomorphisms. Now $5$ is not an idempotent element in $\Bbb Z_{15}$, so the map generated by $1 \to 5$ is not a homomorphism.

However, $10$ is an idempotent element of $\Bbb Z_{15}$. In particular, the subring $T \subset \Bbb Z_{15}$ generated by $10$ has unit $10$. Since it is annihilated by $3$, and consequently by $18$, there is a unital homomorphism $\Bbb Z_{18} \to T$ (i.e., mapping $1$ to $10$). So your second map is a legitimate homomorphism of rings (composing with the injection $T \to \Bbb Z_{15}$).

Basically, the point of this answer is to check that one of your maps preserves the relations of the two rings, while the other doesn't.


Continuing Akhil M's answer above (the comments under it are getting pushed down out of sight): it is also not hard to systematically find all the idempotents in ${\mathbb Z}/n$. Namely, for example with $n=pq$ with distinct primes $p,q$, $\mathbb Z/n \approx \mathbb Z/p \oplus \mathbb Z/q$, by Sun-Ze's theorem (altho' one might carp about what kind of "sum" it is). So, solving the idempotent condition $x^2=x$ mod $pq$ is equivalent to solving that equation mod $p$ and mod $q$. The integers mod a prime form a field, so we know that there are only the two solutions, the obvious ones, $0,1$. Thus, the idempotents mod $pq$ are $0$-or-$1$ mod $p$ and $0-or-1$ mod $q$. Obviously $0$ and $1$ mod $pq$ work, but/and also $0$ mod $p$ but/and $1$ mod $q$, and vice-versa. In the case at hand, both $6$ and $10$ are non-obvious idempotents.