Continued Fraction Calculator NZ

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.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
Advertise on this page
355/113
best rational approximation
Value of fraction3.141593
Error2.7e-7
[3; 7, 15, 1]

Generates continued fraction terms and the convergent (best fraction) for the given number of terms. Rational numbers terminate; irrationals are truncated.

How it works

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.

Worked example

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.

Related calculators