This calculator expands a decimal number into a continued fraction and finds the best simple fraction that approximates it. A continued fraction is a remarkable way of writing a number as a whole part plus a fraction whose denominator is itself a whole part plus a fraction, and so on, nesting downward. Written as a list of whole numbers, it reveals the hidden structure of a number and, crucially, produces the best possible rational approximations for a given size of denominator. This is why continued fractions are prized in number theory, and why they explain practical facts like why 22 over 7, and even better 355 over 113, are such good approximations to pi. They are used in approximating irrational numbers, in calendar design, gear ratios, and computer arithmetic. This tool makes the process visible. You enter a decimal value and the maximum number of terms to compute, and the calculator generates the continued fraction terms, then forms the convergent, the simple fraction built from those terms, which is the best rational approximation. It shows the nearest fraction, its decimal value, and how far that approximation is from your original number. The results update as you type, so you can watch the approximation improve as you allow more terms. Use it to find a neat fraction close to an awkward decimal, to explore number theory, or to understand why certain fractions approximate famous constants so well. A rational number always produces a finite continued fraction that terminates exactly, while an irrational number produces an unending one, which this tool truncates at the number of terms you choose.
Generates continued fraction terms and the convergent (best fraction) for the given number of terms. Rational numbers terminate; irrationals are truncated.
The whole part of the number is taken as the first term. The remaining fractional part is inverted, and its whole part becomes the next term, repeating until the fraction runs out or the term limit is reached. The convergent fraction is built up from these terms, giving the best rational approximation for that depth.
For pi, entered as 3.14159265 with 4 terms, the continued fraction is 3; 7, 15, 1. Building the convergent from these four terms gives 355 over 113, which equals about 3.141593, differing from pi by less than three ten-millionths, an extraordinarily good approximation for such a small denominator.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
© 2019 to 2026 Calculate.co.nz. All rights reserved.