Continued Fraction Calculator
Convert a decimal into a continued fraction and a fraction.
Result
How it is calculated
The tool repeats one step: take the integer part a = floor(x), subtract it, and invert the leftover, x = 1 / (x - a). The collected integers form [a0; a1, a2, ...]. It stops when the remainder drops below 1e-9 (the number has ended) or when it reaches the number of terms you ask for. That limit must be between 1 and 30; a value below 1 falls back to 10 and a value above 30 is cut to 30.
The fraction is built with the recurrence h(n) = a(n)*h(n-1) + h(n-2) and k(n) = a(n)*k(n-1) + k(n-2), giving h / k. The decimal shown is that fraction divided out to six places, so you can see how close it is to your input. Floating-point input means very long expansions of a decimal like 0.333333 end in huge terms: the tool expands the decimal you typed, not the fraction you had in mind.
Worked example
Enter 3.14159 with 3 terms. Integer part 3, remainder 0.14159. Invert: 1 / 0.14159 = 7.06, so the next term is 7, remainder about 0.0626. Invert: 1 / 0.0626 is about 15.99, so the next term is 15. With three terms the expansion is [3; 7, 15]. The recurrence gives 3/1, then 22/7, then 333/106, so the fraction is 333 / 106, which divides out to 3.141509, close to the 3.14159 you typed.
Common mistakes
- Asking for more terms to get a 'cleaner' fraction. More terms give a closer fraction but usually with a much larger denominator; for a gear ratio or a ruler fraction a few terms are often the useful answer.
- Typing a rounded decimal such as 0.333 or 0.33333 and expecting 1/3. The tool expands exactly what you typed, so you get a different, ugly fraction instead.
- Reading the bracket as a list of equal parts. The first number is the whole part and the rest, after the semicolon, are the nested denominators.
- Treating the six-place decimal as the input. It is the value of the fraction found, so compare it with your number rather than copying it back.
About this calculator
This calculator expands a decimal number into its continued fraction representation — a sequence of integer terms [a₀; a₁, a₂, a₃, …] found by repeatedly taking the integer part and inverting the remainder — and shows the convergents, the best rational (fraction) approximations obtainable at each step.
Number theory students and programmers use it to find the simplest fraction that closely approximates a decimal (useful for gear ratios, musical tuning, and calendar systems), and it's a classic way to demonstrate why some numbers like π have infinite non-repeating continued fractions while rational numbers terminate.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Watch for an unusually large term in the bracket. It means the fraction just before it is a remarkably good approximation for its size: for π the term 292 follows the fraction 355 / 113, which is already correct to about six decimals. Past roughly ten terms, a decimal typed with 15 digits is mostly expanding its own rounding, so extra terms stop meaning anything. Which decimal are you trying to approximate, and what denominator limit do you have in mind?