Continued Fraction Calculator
Convert any decimal, fraction, or square root to its continued fraction representation with convergents, step-by-step Euclidean algorithm, and interactive visualization.
Video Guide: Continued Fraction Calculator
About Continued Fraction Calculator
Welcome to the Continued Fraction Calculator — a powerful tool that converts any decimal number, fraction, or square root into its continued fraction representation. See the famous notation [a₀; a₁, a₂, ...], explore rational approximations (convergents), and visualize the nested fraction structure interactively.
What is a Continued Fraction?
A continued fraction is a way of expressing a number as a nested sequence of integer parts and fractions:
Where a₀, a₁, a₂, ... are non-negative integers called partial quotients. The standard notation is [a₀; a₁, a₂, a₃, ...]. Some remarkable examples:
- π (pi) ≈ [3; 7, 15, 1, 292, 1, 1, ...] — the 292 means pi is extremely well approximated by 355/113
- φ (golden ratio) = [1; 1, 1, 1, ...] — the slowest-converging continued fraction
- √2 = [1; 2, 2, 2, ...] — periodic, as predicted by Lagrange's theorem
- e = [2; 1, 2, 1, 1, 4, 1, 1, 6, ...] — beautiful pattern
How the Algorithm Works
For Any Decimal x
- Compute a₀ = ⌊x⌋ (floor of x)
- Set x₁ = 1/(x − a₀), then compute a₁ = ⌊x₁⌋
- Repeat: xₙ₊₁ = 1/(xₙ − aₙ), aₙ₊₁ = ⌊xₙ₊₁⌋
- Stop when the fractional part is zero (rational) or you have enough terms
For a Fraction p/q (Euclidean Algorithm)
For a fraction, the algorithm is identical to the Euclidean algorithm for GCD:
Each division step of the Euclidean algorithm produces one partial quotient of the continued fraction.
Convergents: Best Rational Approximations
The convergents pₙ/qₙ are obtained by truncating the continued fraction at each step. They satisfy a remarkable property: pₙ/qₙ is the best rational approximation to x with denominator ≤ qₙ.
| Number | Convergent | Decimal Approx | Error |
|---|---|---|---|
| π | 3/1 | 3.0 | 0.14 |
| π | 22/7 | 3.142857... | 1.3 × 10⁻³ |
| π | 333/106 | 3.14150... | 8.3 × 10⁻⁶ |
| π | 355/113 | 3.1415929... | 2.7 × 10⁻⁷ |
| √2 | 1/1 | 1.0 | 0.41 |
| √2 | 3/2 | 1.5 | 0.086 |
| √2 | 7/5 | 1.4 | 0.014 |
| √2 | 17/12 | 1.41̅6̅ | 2.5 × 10⁻³ |
Periodic Continued Fractions
By Lagrange's theorem, a real number has a periodic continued fraction if and only if it is a quadratic irrational (solution to a quadratic equation with integer coefficients). This includes all square roots of non-perfect-square integers.
- √2 = [1; 2] — period of length 1
- √3 = [1; 1, 2] — period of length 2
- √7 = [2; 1, 1, 1, 4] — period of length 4
- √94 = [9; 1, 2, 3, 1, 1, 5, 1, 8, 1, 5, 1, 1, 3, 2, 1, 18] — period of length 16
How to Use This Calculator
- Enter a value: decimal (e.g. 2.71828), fraction (e.g. 355/113), or square root (e.g. sqrt(7))
- Set maximum terms: more terms give more partial quotients and convergents
- Click Calculate: see CF notation, animated terms, nested visualization, convergents table, and Euclidean steps (for fractions)
Frequently Asked Questions
What is a continued fraction?
A continued fraction is an expression of the form a₀ + 1/(a₁ + 1/(a₂ + ...)) where a₀, a₁, a₂, ... are integers called partial quotients. Every real number has a continued fraction expansion. Rational numbers have finite expansions; irrational numbers have infinite ones. Quadratic irrationals (like square roots) have periodic expansions.
How do you convert a decimal to a continued fraction?
Take the floor (integer part) as the first term. Subtract it from the number, take the reciprocal, and repeat. For example, π ≈ 3.14159...: floor = 3, remainder = 0.14159..., reciprocal = 7.062..., floor = 7, remainder = 0.062..., reciprocal = 15.996..., floor = 15, giving [3; 7, 15, ...].
Why does sqrt(2) have a periodic continued fraction?
By Lagrange's theorem, a real number has a periodic continued fraction exactly when it is a quadratic irrational. √2 satisfies x² = 2, so it is quadratic irrational, giving [1; 2, 2, 2, ...]. The golden ratio φ = (1 + √5)/2 gives [1; 1, 1, 1, ...] — the simplest possible period.
What are convergents and why are they important?
Convergents are the fractions obtained by truncating the continued fraction. They are the best rational approximations — no fraction with a smaller denominator is closer to the target number. This is why 22/7 and 355/113 are famous approximations to π: they are convergents of π's continued fraction.
How is the continued fraction algorithm related to the Euclidean algorithm?
When the input is a fraction p/q, computing its continued fraction is identical to the Euclidean GCD algorithm. Each remainder-and-quotient step produces exactly one partial quotient. The continued fraction terminates exactly when the GCD is found.
Additional Resources
Reference this content, page, or tool as:
"Continued Fraction Calculator" at https://MiniWebtool.com/continued-fraction-calculator/ from MiniWebtool, https://MiniWebtool.com/
by miniwebtool team. Updated: Feb 18, 2026
Advanced Math Operations:
- Adjacency Matrix Calculator New
- Antilog Calculator
- Beta Function Calculator
- Binomial Coefficient Calculator
- Binomial Probability Distribution Calculator
- Bitwise Calculator Popular
- Boolean Algebra Simplifier Popular
- Central Limit Theorem Calculator
- Chinese Remainder Theorem Calculator
- Combination Calculator
- Complementary Error Function Calculator
- Complex Number Calculator
- Continued Fraction Calculator
- Derangement (Subfactorial) Calculator
- Dijkstra's Shortest Path Calculator
- Entropy Calculator
- Error Function Calculator
- Euler's Totient Function Calculator
- Exponential Decay Calculator
- Exponential Growth Calculator
- Exponential Integral Calculator
- Exponents Calculator
- Extended Euclidean Algorithm Calculator
- Factorial Calculator
- Gamma Function Calculator
- Golden Ratio Calculator
- Graph Coloring Calculator New
- Graph Degree Sequence Validator
- Group Theory Order Calculator New
- Half Life Calculator
- Hamiltonian Path Checker New
- Inclusion-Exclusion Calculator New
- Karnaugh Map (K-Map) Solver New
- Linear Programming Solver Popular
- Markov Chain Steady State Calculator
- Minimum Spanning Tree Calculator
- Modular Exponentiation Calculator New
- Modular Multiplicative Inverse Calculator
- Negative Binomial Distribution Calculator New
- Network Flow Calculator (Max Flow) New
- Percent Growth Rate Calculator Popular
- Permutation Calculator
- Permutations with Repetition Calculator New
- Pigeonhole Principle Calculator
- Planar Graph Checker New
- Poisson Distribution Calculator
- Polynomial Roots Calculator
- Primitive Root Calculator
- Probability Calculator
- Probability Distribution Calculator
- Proportion Calculator
- Quadratic Formula Calculator
- Ring and Field Calculator New
- Rounding Calculator Popular
- Scientific Calculator
- Scientific Notation Calculator Popular
- Set Theory Calculator
- Significant Figures Calculator New
- Stable Marriage Problem Solver New
- Stirling Numbers Calculator
- Sum of Cubes Calculator
- Sum of Positive Integers Calculator
- Sum of Squares Calculator
- Topological Sort Calculator New
- Traveling Salesman Solver (TSP) New
- Truth Table Generator
- Venn Diagram Generator (3 Sets)