Fraction Tree and Continued Fractions

This Demonstration is a game for exploring connections between the Stern–Brocot tree and continued fractions.
The primary challenge is to reach a destination fraction in the tree using the arrow buttons. You can follow your progress with the "fraction tree" tab.
Once you have figured out how the fraction tree works, try to solve problems using the other tabs. Use the arrow buttons to change your position in the Stern–Brocot tree. Your position in the tree will change even while using other tabs.


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


Snapshot 1: The fraction has been reached in the Stern–Brocot tree. It is possible to display up to 20 levels on the screen. Beyond five levels it is easier to keep track of the order of fractions using the "ordering" tab.
Snapshot 2: The same solution is shown in the order of the fractions visited. The ordering corresponds to collapsing the Stern–Brocot path onto a single dimension. The solution was reached by turning left, right, left, right.
Snapshot 3: The fraction is shown as the mediant of and ; it was produced by summing the parents' numerators to produce the numerator of the mediant and summing the parents' denominators to produce the denominator of the mediant. This method, although incorrect as a way to add fractions, is the very way to produce a mediant. The mediant always lies between the parent fractions.
Snapshot 4: Click the "continued fraction" tab to keep track of turns in the tree and to show how the continued fraction is built up from partial quotients.
Snapshot 5: Click the "plotted fractions" tab to show how the fractions converge (or not) on the goal fraction. In the snapshot, the current slope is ; the desired slope is . All visited fractions, not only the convergents, are displayed in the plot.
This Demonstration was developed under the auspices of the Poincaré Institute for Mathematics Education at Tufts University and TERC, an NSF-funded Math and Science Partnership project (NSF MSP DUE-0962863).
[1] R. L. Graham, D. E. Knuth, and O. Patashnik, Concrete Mathematics: A Foundation for Computer Science, Reading, MA: Addison–Wesley, 1994.
[2] H. M. Stark. "Number Theory from a Continued Fractions Viewpoint," An Introduction to Number Theory, Cambridge, MA: MIT Press, 1970 pp. 181–256.
    • 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.