Calkin-Wilf Tree of Fractions

The Calkin–Wilf tree contains all positive fractions in reduced form. Click the buttons to move down to the left or right, or to move up. The fraction's index is shown in decimal and binary notation to highlight the connections between the binary expansion of the index and the fraction's position in the tree.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


The rank (or index) assigned to a fraction can be thought of as its address in the Calkin–Wilf tree. Since the tree is binary, you can move from one node to another in three ways: down to the left child node or right child node, or up to the parent node. You can also move to a randomly selected point in the tree or reset the visible part of the tree to the root position.
In fraction mode, the left button adds the numerator to the denominator and the right button adds the denominator to the numerator (leaving the other unchanged in both cases), while the up button replaces the larger of the two by their difference.
In index mode, the left and right children of node have indices and , respectively. Both modes show the binary representation of the index code of the node at the top of the displayed subtree, starting with a 1 and continuing with precisely the bits (0 or 1) indicated by pushing the buttons. The bits of the index thus provide a "breadcrumb trail" for the path down the tree. Moving back up the tree corresponds to lopping off the last bit, or dividing the index by 2, discarding the remainder.
The Calkin–Wilf enumeration provides a one-to-one mapping of the positive rationals onto the positive integers, thus demonstrating that the set of rational numbers is countably infinite. The Stern–Brocot tree gives an alternative, related enumeration.
[1] N. Calkin and H. S. Wilf, "Recounting the Rationals," The American Mathematical Monthly, 107(4), 2000 pp. 360–363.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+