Figure 1 Given a real number, R, this algorithm computes the ais for a simple continued fraction.

Algorithm A:

        x = R;
        i = O;
        a[ i ] = integer_part( x );

        while ( fractional_part( x ) != 0.0 )
        {
                x = 1.0 / fractional_part( x );
                i = i+1;
                a[ i ] = integer_part( x );
        }