Counting infinity
Why the rationals can be numbered
Numbering pairs of integers
The starting point is the enumeration of along successive diagonals. We first go through the pairs whose coordinates sum to , then , then , and so on. Each diagonal contains only finitely many pairs, so the traversal reaches every pair in finite time.
| Diagonal | Pairs visited | Ranks assigned |
|---|---|---|
| , | , | |
| , , | , , | |
| , , , | to |
Cantor's pairing formula gives the rank explicitly:
It is a bijection from onto : is countable.
is countable
Every strictly positive rational can be written uniquely as in lowest terms, with and coprime strictly positive integers. The map
is therefore an injection from into , which is countable. Since an infinite subset of a countable set is countable, so is .
We conclude by putting the pieces together: is the union of , and , hence a finite union of countable sets — it is countable.
A concrete enumeration
The positive rationals can also be enumerated by increasing height, where the height is the sum of the reduced form, ordering by increasing numerator for equal heights:
Fractions not in lowest terms, such as , are skipped to avoid repetitions. Since each height gives only finitely many fractions, every rational eventually appears, exactly once.
Algebraic numbers too
The same argument goes further than you might think. An algebraic number is a root of a nonzero polynomial with integer coefficients. Now, for a fixed degree and a fixed bound , there are only finitely many polynomials with integer coefficients bounded by , each having at most roots.
The set of algebraic numbers is therefore a countable union of finite sets: it is countable. This remark, combined with the next chapter, will produce a spectacular result.
Classic pitfall
Proposing as an enumeration of the traversal "first all the , then all the , and so on." This list never finishes the first row, so it never reaches : it is not an enumeration. A proper bijection must assign every element a finite rank, which is guaranteed by cutting into finite slices — diagonals or heights.

