Calcoid

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.

Convert between decimals, fractions, and continued fractions

Continued fraction

[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, ...]

Best rational approximation: 1146408 / 364913 = 3.1415926536

Terms

10

Decimal value

3.1415926536

Type

Truncated

Convergents (successive rational approximations)

Each convergent is the best rational approximation with a denominator no larger than its own.

na_nFractionValueAccuracy
033 / 1395.49%
1722 / 73.14285799.96%
215333 / 1063.141509100.00%
31355 / 1133.141593100.00%
4292103993 / 331023.141593100.00%
51104348 / 332153.141593100.00%
61208341 / 663173.141593100.00%
71312689 / 995323.141593100.00%
82833719 / 2653813.141593100.00%
911146408 / 3649133.141593100.00%

Continued Fraction Examples

Input ModeInputContinued FractionFractionDecimal
Decimal to continued fraction1.5[1; 2]3/21.5
Fraction to continued fraction22 / 7[3; 7]22/73.142857
Terms to fraction3, 7, 15, 1[3; 7, 15, 1]355/1133.141593
Terms to fraction1, 2, 2, 2[1; 2, 2, 2]17/121.416667
Terms to fraction2, 1, 2, 1, 1[2; 1, 2, 1, 1]19/72.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"

See all 202 calculators in "Math"