There is a simple algorithm for obtaining the continued fraction of any positive number, based on the repeated extraction of the integer part.
Observation — Algorithm for computing the continued fraction of a number
Given , write with the integer part and . If , consider and repeat: , and so on. For the process terminates; for it goes on forever. The expansion is periodic if and only if is a quadratic irrational (a root of a second-degree equation with rational coefficients), a result proved by Lagrange (cf. Stillwell, ch. 5).
Links
Topics: Second-degree equations
Concepts: Algorithm · Continued fraction · Quadratic irrational
Skills: Using formulas
People: Joseph-Louis Lagrange