function [ p, q ] = r8cf_evaluate ( n, a, b )

%*****************************************************************************80
%
%% r8cf_evaluate() evaluates a continued fraction with R8 entries.
%
%  Discussion:
%
%    For convenience, we omit the parentheses or multiline display.
%
%    CF = A(0) + B(1) / A(1) + B(2) / A(2) + ... A(N-1) + B(N) / A(N).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 August 2017
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, describes the number of terms.
%
%    real A(0:N), B(1:N), the continued fraction
%    terms.
%
%  Output:
%
%    real P(0:N), Q(0:N), the numerators
%    and denominators of the successive partial sums of the continued
%    fraction.
%
  p = zeros ( 1, n + 1 );
  q = zeros ( 1, n + 1 );

  for i = 0 : n

    if ( i == 0 )
      p(i+1) = a(i+1) * 1.0 + 0.0;
      q(i+1) = a(i+1) * 0.0 + 1.0;
    elseif ( i == 1 )
      p(i+1) = a(i+1) * p(i) + b(i+1) * 1.0;
      q(i+1) = a(i+1) * q(i) + b(i+1) * 0.0;
    else
      p(i+1) = a(i+1) * p(i) + b(i+1) * p(i-1);
      q(i+1) = a(i+1) * q(i) + b(i+1) * q(i-1);
    end

  end

  return
end
