Continued Fraction Calculator
Convert any decimal or fraction to a continued fraction [a0; a1, a2, ...] and back. Shows every convergent (best rational approximation) with accuracy.
Continued Fraction Examples
| Input Mode | Input | Continued Fraction | Fraction | Decimal |
|---|---|---|---|---|
| Decimal to continued fraction | 1.5 | [1; 2] | 3/2 | 1.5 |
| Fraction to continued fraction | 22 / 7 | [3; 7] | 22/7 | 3.142857 |
| Terms to fraction | 3, 7, 15, 1 | [3; 7, 15, 1] | 355/113 | 3.141593 |
| Terms to fraction | 1, 2, 2, 2 | [1; 2, 2, 2] | 17/12 | 1.416667 |
| Terms to fraction | 2, 1, 2, 1, 1 | [2; 1, 2, 1, 1] | 19/7 | 2.714286 |
Frequently Asked Questions about the Continued Fraction Calculator
What is a continued fraction and what does [a0; a1, a2, ...] mean?
A simple continued fraction expresses a number x as x = a0 + 1 / (a1 + 1 / (a2 + 1 / (a3 + ...))), where a0 is any integer and a1, a2, a3, ... are positive integers called the partial quotients. The standard shorthand is [a0; a1, a2, a3, ...], with a semicolon after the integer part and commas separating the rest. For example, 22 / 7 = 3 + 1 / 7 is written [3; 7], and the golden ratio is [1; 1, 1, 1, 1, ...] because phi = 1 + 1 / (1 + 1 / (1 + 1 / (1 + ...))). Every rational number has a finite continued fraction (the algorithm terminates exactly when the remainder hits zero), and every irrational number has a unique infinite continued fraction. Continued fractions reveal arithmetic structure that decimal expansions hide: a periodic continued fraction means the number is a quadratic irrational (a root of an integer quadratic), and the partial quotients tell you how easily the number can be approximated by simple fractions.
Why are convergents the best rational approximations?
A convergent is formed by truncating the continued fraction. Convergents are best approximations in precise denominator-based senses, but an intermediate or semiconvergent fraction can be closest under an arbitrary denominator cap. For pi, 22 / 7 and 355 / 113 are famous convergents. The large partial quotient 292 after 355 / 113 explains its unusual accuracy.
How is the Euclidean algorithm the same as fraction-to-continued-fraction?
The fraction-to-continued-fraction algorithm and the Euclidean algorithm for gcd are literally the same computation; you just keep different bookkeeping. Take 22 / 7. Divide: 22 = 3 * 7 + 1, quotient 3 (this is a0), remainder 1. Now invert and repeat with 7 / 1: 7 = 7 * 1 + 0, quotient 7 (this is a1), remainder 0. Stop. The terms are [3; 7], and the last non-zero remainder is gcd(22, 7) = 1. For 1071 / 462: quotients are 2, 3, 7, so the continued fraction is [2; 3, 7] and gcd(1071, 462) = 21 (the last non-zero remainder before the algorithm terminates). The reason this works is structural: each step computes a_i = floor(p / q), then replaces (p, q) with (q, p mod q). The quotients are the partial quotients of the continued fraction; the remainders are the intermediate gcd values. This calculator's fraction-to-cf mode is exactly the Euclidean algorithm, with the quotients reported instead of just discarded.
Why is 22 / 7 the famous approximation of pi?
22 / 7 is the second convergent of pi's continued fraction [3; 7, 15, 1, 292, ...], after 3 / 1. It differs from pi by about 0.00126 and is easy to remember. Later convergents are more accurate: 333 / 106 differs by about 0.000083 and 355 / 113 by about 0.000000267.
What are noble numbers and why is the golden ratio the most irrational?
A noble number has a continued fraction that eventually consists entirely of 1s. The golden ratio is [1; 1, 1, 1, ...]. Calling it the most irrational refers to a specific Diophantine-approximation sense: its convergents improve relatively slowly compared with numbers that have larger partial quotients. It is not a general ranking of every property of irrational numbers.
Related Calculators
More calculators in "Math"
Cosine Similarity CalculatorPolynomial Long Division CalculatorPolynomial CalculatorCombinations and Permutations CalculatorMatrix Determinant CalculatorMatrix Multiplication Calculator
See all 202 calculators in "Math"