How to prove that the set of rational numbers are countable? [duplicate]

Can any one tell me how to prove that the set of rational numbers are countable? Prove give me a prove?

Thanks.


Map each rational $\frac{a}{b}$ into the integer $2^a 3^b$. This shows that the number of rationals is at most the number of integers.

If you want to handle the negative rationals, map the sign ($-1$, $0$, or $+1$) to $5^{\mathrm{sign}+1}$ and stick it on the end, so the mapping is $\mathrm{sign} \times \frac{a}{b} \to 2^a \, 3^b \,5^{\mathrm{sign}+1}$.

If you find this troubling, that's OK. You are not the only one.


Here is another argument:

Consider the map $\varphi:\mathbb{Q}\rightarrow \mathbb{Z}\times\mathbb{N}$ which sends the rational number $\frac{a}{b}$ in lowest terms to the ordered pair $(a,b)$ where we take negative signs to always be in the numerator of the fraction. This map is an injection into a countably infinite set (the cartesian product of countable sets is countable), so therefore $\mathbb{Q}$ is at most countable. Since $\mathbb{Q}$ is not finite, it must be countably infinite.


For an explicit enumeration of positive rationals, you can use the Calkin-Wilf sequence: $$q_{i+1}= \frac{1}{ \lfloor q_i \rfloor +1 - \{q_i\} }, \ q_0=1.$$

More details can be found in Proofs from THE BOOK.