Find the set of all homomorphisms from $(\mathbb{Z},+)$ onto $(\mathbb{Z}_6,+)$. Find the set of all homomorphisms from $(\mathbb{Z},+)$ onto $(\mathbb{Z}_6,+)$.
My solution goes like this:

We first try to find out all the homomorphisms from $(\mathbb{Z},+)$ to $(\mathbb{Z}_6,+)$. Now, assuming $f$ as a homomorphism from $(\mathbb{Z},+)$ to $(\mathbb{Z}_6,+)$. We know that, $f(a^n)=nf(a)$, where $a\in \mathbb {Z},n\in \mathbb {Z}$( $a^n=\underbrace{a.a.a...a}_\text{n times}$, where $.$ is the binary operation associated with the group $\mathbb {Z}$ , which is $+$ in this case , so $a^n=na$, $a\in \mathbb {Z}$). If $a=1$ , then $f(1^n)=nf(1)$ due to which $f(n)=nf(1)$. Now, $f$ is completely known if $f(1)$ is known. So, if $f(1)=[m]$, such that $[m]\in \mathbb {Z}_6 $, then, $f(n)=n[m]$. So, $f(n)=n[m]=[nm]$. Now, if $a,b\in\mathbb {Z}$ , then, $f(a+b)=(a+b)[m]=[m]a+[m]b=[ma]+[mb]=f(a)+f(b)$, so, $f$ is a homomorphism.  Now, we check which of these homomorphisms are actually an onto homomorphism i.e epimorphisms. So, $[p]\in\mathbb {Z}_6$, so, if $f$ is onto then, $\exists a\in\mathbb {Z}$ such that $f(a)=[p]$. Now, $f(a)=a[m]$. So, $[am]=[p]$. Now, if $m=0,1,2,3,4,5$, then $am=0,a,2a,3a,4a,5a$ respectively. If $m=0$ , then $f$ is a trivial homomorphism i.e $f$ maps every element of $a$ to $[0]$, so , $f$ is not onto. If $m=1$, then $[am]=[a]$, then , $\forall p\in\mathbb {Z}_6$, then, we choose $a=p$, so, $f(p)=[p]\in\mathbb {Z}_6$ . Thus, if $m=1$, then $f$ is onto. If $m=2$, then $am=2a$. If $p=1$, then, if $[2a]=[1]$, then $2a\equiv 1\pmod 6$, which is clearly a contradiction as $2a\equiv 1\pmod 6$ implies $2a-1=6k$ or $2a-6k=1$ which means $2|1$ , a contradiction . Similarly we can easily show that $m\neq 3,4$. If $m=5$,  $f$ is onto then, $\exists a\in \mathbb {Z}$, such that, $[5a]=[m]$, so, $5a\equiv m\pmod 6$. Now, $5\equiv -1\pmod 6$ . So,$5k\equiv -k\pmod 6$ . We can choose $k\in\mathbb {Z}$, such that $k\equiv -m\pmod 6$ , then, $5k\equiv m\pmod 6$. So, if $m=5$, we see that $f$ is onto. Thus if $f(a)=[a] $ or $f(a)=[5a]$, then $f$ is an onto homomorphism.  So, there are only two onto homomorphisms or epimorphisms from $(\mathbb{Z},+)$ onto $(\mathbb{Z}_6,+)$.

Is the above solution valid? If not, where is it going wrong? Is there any other shorter method to do these sort of problems? Is this a standard way to solve these sort of problems?
 A: You are correct except that I think u also need to consider $f(-1)$, since this is just a additive homomorphism and not multiplicative. We have $f(1)+f(-1) = f(1-1) = f(0) = 0$. So $f(1) = -f(-1)$. A simpler short cut may be with $f(1) = m$, $f(-1) = [-m]$ with $0 \leq m \leq 5$, $f$ is onto iff $[m\mathbb{Z}_6] = \mathbb{Z}_6$, Hence true for all $m$ such that $gcd(m,6) = 1$. So $m \in \{1,5\}$.
A: $\Bbb Z_6$ has $\varphi (6)=2$ generators.   Since $\Bbb Z$ is cyclic, a homomorphism out of it is determined by where a generator,  say $1$, goes.   You can choose either generator of $\Bbb Z_6$ for $h(1)$.  Thus there are two surjective homomorphisms $h:\Bbb Z\to \Bbb Z_6$.
You can do $h(1)=1$ or $h(1)=5$.  Note that in either case the kernel is isomorphic to $6\Bbb Z$, since $h(1)$ has order $6$.  So everything checks out with the first isomorphism theorem.

A little extra:  $\Bbb Z$ as a free group (on one generator) enjoys the universal property.   Namely,  there's a unique homomorphism into any group extending any choice of target for the generator.
That's $\Bbb Z$ is a free object in the category of groups.
In the case of $Z_6$, there are thus $6$ homomorphisms total.  Two surjective.
