# Thread: Z and Q are countable

1. ## Z and Q are countable

I'm reading the text about the proof of Z and Q are countable.

$\mathbb {Z}$ is the union of the countable sets $\mathbb {N} \ , \ \{ -n : n \in \mathbb {N} \} \ , \ \{ 0 \}$, and one can define a surjection $f: \mathbb {Z} ^2 \rightarrow \mathbb {Q}$ by $f(m,n) = \frac {m}{n}$ if $n \neq 0$ and $f(m,0) = 0$

End of proof.

I understand that basically the system of Z and Q are equivalent, so if Z is countable so is Q, but where in the proof did it show that there exist an injection from Z to the set of natural numbers? Thanks.

$f:\mathbb{Z} \mapsto \mathbb{N}\;,\,f(n) = \left\{ {\begin{array}{rl}