Continued Fraction Calculator
Expand any decimal or fraction into its continued fraction and see every convergent — the best rational approximation at each step, with the error shown.
🔒 This tool runs entirely in your browser. Your files are never uploaded to a server.
Continued Fraction Calculator
Enter a decimal or a/b fraction to see its continued fraction expansion and the convergents that approximate it.
Accepts a decimal (3.14159) or a simple a/b fraction (355/113). Everything runs locally in your browser.
How it works
A continued fraction is built by repeatedly taking the integer part of a number, then inverting what's left and repeating:
a0 = floor(x) x1 = 1 / (x - a0) a1 = floor(x1) x2 = 1 / (x1 - a1) ...
The resulting sequence [a0; a1, a2, ...] is the continued fraction. The convergents — the best rational approximations at each stage — are built back up from the terms using the standard recurrence:
h_n = a_n · h_(n-1) + h_(n-2) k_n = a_n · k_(n-1) + k_(n-2)
For π, this produces [3; 7, 15, 1, 292, 1, ...] with convergents 3, 22/7, 333/106, and 355/113 — the last one, discovered over 1,500 years ago, is accurate to 6 decimal places despite a denominator under 200.
FAQ
What is a continued fraction?
A way of writing a number as an integer plus a fraction whose denominator is itself an integer plus a fraction, and so on — written [a0; a1, a2, a3, ...]. Every real number has one; a rational number's expansion terminates, an irrational number's continues forever.
What are convergents, and why are they useful?
A convergent is the fraction you get by cutting the continued fraction off after a given number of terms — it is provably the best possible rational approximation with a denominator that small. That is exactly how 22/7 and the more accurate 355/113 are derived for π.
Can I enter a fraction instead of a decimal?
Yes — type it as a/b, like 355/113, and the calculator expands that ratio directly.
Does this work for negative numbers?
Yes. The integer part of the first term carries the sign; the calculator handles it automatically.
Why does the expansion stop after a certain number of terms?
Either you hit the max-terms limit, or the calculator reached the point where floating-point precision runs out — a computer can only represent a decimal to about 15-17 significant digits, so a truly infinite expansion (like π's) will always be cut short eventually.
How we compare
| Feature | Online Tool Store | Manual long division | A general symbolic math CAS |
|---|---|---|---|
| Instant, in the browser, no install | Yes | Slow by hand | Requires software |
| Shows every convergent and its error | Yes | Tedious to compute | Usually yes |
| Accepts a plain fraction (a/b) directly | Yes | N/A | Usually yes |
| Free, no sign-up | Yes | N/A | Often paid |
For a quick rational approximation with the error shown at every step, this is faster than a manual expansion and needs no math software installed.