← All tools

Continued Fraction & Best Rational Approximation

Expand a number or fraction into its simple continued fraction [a₀; a₁, a₂, …], list its convergents (the sequence of best rational approximations), and find the closest fraction whose denominator stays within a bound you choose. All arithmetic is exact (BigInt) — paste 355/113, 22/7, a decimal like 3.14159, or any integer. Runs locally in your browser.

Input

Number / fraction

Convergents

Best rational approximation

Max denominator

A simple continued fraction writes a number as a₀ + 1/(a₁ + 1/(a₂ + …)), abbreviated [a₀; a₁, a₂, …]. Each convergent pₙ/qₙ (formed by the recurrence pₙ = aₙ·pₙ₋₁ + pₙ₋₂, same for q) is a best rational approximation — no fraction with a smaller denominator is closer. The best rational approximation with denominator ≤ N is found among the convergents and their semiconvergents; this tool checks them all exactly. Decimals become exact rationals (e.g. 3.14159 → 314159/100000), so every result is exact to the input you give. Negative inputs are taken as absolute value. Pairs with the GCD/LCM and Fraction Calculator tools. Everything runs locally — nothing leaves your browser.