WOLFRAM|DEMONSTRATIONS PROJECT

Two Enumerations of the Rationals

​
integer
62947327
numerator
355
denominator
113
Calkin-Wilf
Stern-Brocat
other system
integer
62947327
is
439
29
355
113
67107847
fraction
355
113
is
67107847
62947327
439
29
Here are two methods for enumerating the rational numbers. The Calkin–Wilf method starts with
1
1
corresponding to the binary number 1. If the binary number
x
corresponds to the fraction
a
b
, then the binary number corresponding to
a
a+b
is 0 appended to
x
, and the one corresponding to
a+b
b
is 1 appended to
x
. According to this scheme, the Calkin–Wilf enumeration begins with

1
1
;
1
2
,
2
1
;
1
3
,
3
2
,
2
3
,
3
1
;
1
4
,
4
3
,
3
5
,
5
2
,
2
5
,
5
3
,
3
4
,
4
1
;⋯
, where semicolons separate the rows of an array.
The Stern–Brocat method is more complicated, but it winds up reversing the Calkin–Wilf binary number except for the leading 1. The corresponding enumeration then reads

1
1
;
1
2
,
2
1
;
1
3
,
2
3
,
3
2
,
3
1
;
1
4
,
2
5
,
3
5
,
3
4
,
4
3
,
5
3
,
5
2
,
4
1
;⋯
.
Since either of the above arrays can be put into one-to-one correspondence with the set of natural numbers (positive integers) , the rationals must also comprise a set of cardinality
ℵ
0
.