StatGardenREF. DESK
Calculators/Maths/Continued fraction expansion
Maths

Continued fraction expansion calculator

Expands a fraction p/q into continued-fraction terms and lists its convergents.

Published 8 August 2026 · Updated 23 September 2026

What this calculator does

A continued fraction rewrites a number as a whole part plus one over a whole part plus one over another, and so on. The expansion terminates for any rational number, and the terms encode its structure remarkably compactly.

The convergents are the payoff: each is the best rational approximation with a denominator that size. Expanding 355 over 113 gives [3; 7; 16], and that fraction is the famous approximation to pi accurate to seven digits.

The formula

Formulaa₀=⌊p/q⌋, then repeat on the reciprocal of the remainder; convergents hₙ=aₙhₙ₋₁+hₙ₋₂, kₙ=aₙkₙ₋₁+kₙ₋₂

The whole part is taken, then the process repeats on the reciprocal of the remainder. Each step yields one term, and the convergents are built up from those terms by a recurrence.

TermMeaning
Continued fractionA number written as nested reciprocals of whole numbers.
ConvergentA partial expansion, giving the best rational approximation for its denominator.
TermsThe whole numbers appearing at each level of the nesting.

The inputs explained

FieldWhat to enter
Numerator pThe numerator of the fraction to expand.
Denominator qThe denominator. Cannot be zero.

When to use it

Finding a good rational approximation

Convergents are provably the best approximations for their denominator size.

Understanding pi approximations

22/7 and 355/113 are both convergents of pi.

Working with gear ratios

Approximating an awkward ratio with small whole numbers is exactly this problem.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How does the denominator change the expansion?

The same numerator over three denominators.

Numerator held at 355
DenominatorContinued fractionFinal convergent
355/7[50; 1; 2; 2]355/7
355/100[3; 1; 1; 4; 2]71/20
355/113[3; 7; 16]355/113
355 over 113 expands to just [3; 7; 16], three terms for a fraction famous as a pi approximation. Over 100 it needs five terms and simplifies to 71/20, and over 7 it gives [50; 1; 2; 2].

Questions

Why is 355/113 special?

Because it approximates pi to seven decimal places with a denominator of only 113, which is remarkable efficiency. It arises as a convergent of pi's continued fraction, and the unusually large next term is what makes it so accurate.

Do all numbers have a continued fraction?

Yes. Rational numbers give finite expansions, which is why this calculator terminates. Irrational numbers give infinite ones, and quadratic irrationals like the square root of two give infinite but periodic expansions.

What makes convergents the best approximations?

A theorem guarantees that no fraction with a denominator smaller than a given convergent comes closer to the target. That optimality is what makes continued fractions the right tool for rational approximation.

What is the continued fraction for the golden ratio?

All ones: [1; 1; 1; 1; ...]. That makes it the hardest number to approximate rationally, since every term contributes the minimum possible. It is sometimes called the most irrational number for exactly that reason.

For the ratio with the simplest expansion, see the golden ratio calculator. For the sequence whose ratios converge to it, see the Fibonacci calculator.