Tool to compute continued fractions. A continued fraction is the representation of a number N in a form of a series of integers (a0, a1, …, an) such as N = (a0+1/(a1+1/(a2+1/(…1/(an))).
Continued Fractions - dCode
Tag(s) : Series
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
A continued fraction is a number expressed as a nested fraction, constructed from integers.
It is written in the general form: $$ a_0 + \cfrac{1}{ a_1 + \cfrac{1}{ a_2 + \cfrac{1}{ a_3 + \cdots}}} $$
or, in abbreviated form: $ [ a_0;a_1;a_2;a_3;\dots ] $
The coefficient $ a_0 $ is an integer, and the subsequent coefficients $ a_1, a_2, \ldots $ are strictly positive integers.
A continued fraction is said to be finite when the expansion stops after a finite number of steps. It then represents exactly a rational number.
A continued fraction is said to be infinite when the expansion continues indefinitely. It then represents an irrational number.
The principle of continued fraction expansion relies on Euclid's algorithm for Euclidean division, as with calculating the greatest common divisor (GCD).
Each quotient obtained corresponds to a coefficient of the continued fraction.
The rational fraction approximating pi, $ \frac{355}{113} = 3.14159292035\ldots $, follows from the fact that $$ 355 = 113 \times \fbox{3} + 16 \\ 113 = 16 \times \fbox{7} + 1 \\ 16 = 1 \times \fbox{16} + 0 $$ The successive quotients are $ 3 $, $ 7 $, and $ 16 $. The corresponding continued fraction is therefore $ [3,7,16] $
Some developments of continuous fractions are infinite
To find the corresponding fraction, use the irreducible fraction tool.
The convergents of a continued fraction are the rational fractions obtained by successively truncating its expansion.
For a continued fraction $[a_0;a_1;a_2;a_3;\dots]$, the nth convergent is $[a_0;a_1;a_2;\dots;a_n]$.
The convergents provide the best rational approximations of the number represented.
Calculate an approximate value of the root (approximation as accurate as possible) and dCode will provide the corresponding continuous fraction.
The easiest way is to use cfrac: $$ e=2+\cfrac{1}{1+\cfrac{1}{2+\cfrac{1}{ 1+\cfrac{1}{1+\cfrac{1}{4+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{6+\cdots}}}}}}}} $$
But the shortest way is to write $$ e = [2 ; 1, 2, 1, 1, 4, 1, 1, 6, \cdots] $$
Most known continued fractions are:
— Square Root of 2: $ \sqrt{2} = [1;2,2,2,2,2,\cdots] $
— Golden Ratio: $ \Phi = [1;1,1,1,1,1,\cdots] $
dCode retains ownership of the "Continued Fractions" source code. Any algorithm for the "Continued Fractions" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Continued Fractions" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Continued Fractions" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Continued Fractions" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Continued Fractions on dCode.fr [online website], retrieved on 2026-03-01,