fraction representation. Each rational can be represented in exactly two ways, since . Usually the first, shorter one is chosen as the canonical representation. The simple continued fraction representation of an irrational number is unique. (However, additional representations are possible when using generalized continued fractions; see below.) The real numbers whose continued fraction eventually repeats are precisely the quadratic irrationals. For example, the repeating continued fraction is the golden ratio, and the repeating continued fraction is the square root of 2. In contrast, the decimal representations of quadratic irrationals are apparently random. The square roots of all (positive) integers that are not perfect squares are quadratic irrationals, and hence are unique periodic continued fractions. The successive approximations generated in finding the continued fraction representation of a number, that is, by truncating the continued fraction representation, are in a certain sense (described below) the "best possible". Basic formula A (generalized) continued fraction is an expression of the form where ai and bi can be any complex numbers. When bi = 1 for all i the expression is called a simple continued fraction. When the expression contains finitely many terms, it is called a finite continued fraction. When the expression contains infinitely many terms, it is called an infinite continued fraction. When the terms eventually repeat from some point onwards, the expression is called a periodic continued fraction. Thus, all of the following illustrate valid finite simple continued fractions: For simple continued fractions of the form the term can be calculated using the following recursive formula: where and From which it can be understood that the sequence stops if . Calculating continued fraction representations Consider a real number . Let be the integer part of and let be the fractional part of . Then the continued fraction representation of is , where is the continued fraction representation of . To calculate a continued fraction representation of a number , write down the integer part (technically the floor) of . Subtract this integer part from . If the difference is 0, stop; otherwise find the reciprocal of the difference and repeat. The procedure will halt if and only if is rational. This process can be efficiently implemented using the Euclidean algorithm when the number is rational. The table below shows an implementation of this procedure for the number 3.245, resulting in the continued fraction expansion [3; 4,12,4]. {| class="wikitable" |- |+ Find the