Continued Fraction Generator
A continued fraction turns an ordinary fraction into a chain of whole numbers, and the partial results along the way — the convergents — have a remarkable property: none of them can be beaten by any fraction with a denominator that small. This computes the expansion, lists every convergent, and then checks both claims: folding the chain back up must give your fraction exactly, and no smaller denominator may do better.
What this generator does
Runs Euclid's algorithm to produce the continued fraction terms, then builds every convergent from the standard recurrence. The expansion is folded back up and compared against your fraction, and each convergent is tested against every smaller denominator.
How to use this tool
- Enter a numerator and a denominator.
- Read the expansion in bracket notation.
- Look down the convergents: each is closer than the last.
- Try 355 over 113 to see where the famous approximation to pi comes from.
Understanding the controls
- Numerator and denominator
- Any fraction up to four digits each. It is reduced to lowest terms first, so 2/4 and 1/2 give identical expansions.
Common use cases
- Finding the convergents of a fraction for a number theory exercise
- Showing where approximations like 22/7 actually come from
- Teaching continued fractions with checkable worked output
- Reducing a gear or timing ratio to a simpler one that is nearly as good
- Exploring the connection between continued fractions and Euclid's algorithm
How this generator works
Each term is the whole part of the current fraction, and what remains is inverted and fed back in — which is exactly Euclid's algorithm, and why the expansion always terminates for a fraction. Convergents come from the standard recurrence rather than by refolding each prefix, which keeps them exact. Before display the whole chain is folded back up and must reproduce the original numerator and denominator, and every convergent after the first is checked against every fraction with a denominator at most its own.
Randomness and fairness
Nothing here is random. A fraction has exactly one continued fraction expansion of this form.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Only finite continued fractions are produced, because only rational numbers are accepted — irrational values like the golden ratio have infinite expansions.
- The first convergent is just the whole part and is not a best approximation in the closest-value sense, which the tool states rather than glosses over.
- Very large numerators and denominators are rejected to keep every step within exact integer arithmetic.
- Only the canonical expansion is shown; every rational also has a second form ending in one.
Privacy and your data
The expansion is computed in your browser and the numbers you enter are never transmitted, stored or included in analytics.
Related generators
- Best Rational Approximation GeneratorFinds the closest fraction to a decimal within a denominator limit, proved by testing every denominator up to that limit.
- Egyptian Fraction GeneratorExpands a fraction into distinct unit fractions by the greedy method, added back up in exact big integers to prove the sum.
- Farey Sequence GeneratorLists every fraction between 0 and 1 with a bounded denominator, in order, with the neighbour identity checked on every consecutive pair.
- Random Fraction GeneratorA proper fraction, automatically simplified to its lowest terms, with its decimal equivalent shown.