homechevron_rightStudychevron_rightMathchevron_rightAlgebrachevron_rightNumber theory

Continued fraction

The calculator represents a fraction as continued fraction

The calculator below represents a given rational number as a finite continued fraction. It also shows the continued fraction coefficients (first coefficient is the integer part). Read more on continued fractions just below the calculator.

PLANETCALC, Continued fraction

Continued fraction

Continued fraction
 

Continued (recurring) fraction

Continued or recurring fraction is a number representation kind as a sum of the number integer part and the fractional part. The fractional part numerator is always one, the denominator is the sum of the integer part and the fractional part. The fractional part denominator may again contain the sum of integer and fractional part and so on.
a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{ \ddots + \cfrac{1}{a_n} }}}
a0,a1,a2...an is the continued fraction coefficients.
We use the following algorithm to calculate continued fraction coefficients:

// n - the fraction numerator
// d - the fraction denominator

loop while d ≠ 0
        r ⟵  n mod d;
        output ⟵ (n-r)/d;
        n ⟵ d;
        d ⟵ r;
 end loop  
Creative Commons Attribution/Share-Alike License 3.0 (Unported) PLANETCALC, Continued fraction

Comments