Question on proving that the rationals are countably infinite

29 Views Asked by At

I just a question on a proof for the rationals being countably infinite from a textbook. We consider the following function, a mapping from $\Bbb Q$ to $\Bbb N$

$$f(x) = \begin{cases} 0, & \text{if $x$ = 0} \\ 2^m 3^n, & \text{if $x$ > 0} \\ 2^m 3^n \cdot 5 &\text{if $x$ < 0} \end{cases} where\ x = \frac mn \ and \ gcd(m,n) = 1 $$

One can see that it is injective by the uniqueness of prime factorization but how is it surjective?