function d = r8poly_degree ( d, c )

%*****************************************************************************80
%
%% r8poly_degree() returns the degree of a polynomial.
%
%  Discussion:
%
%    The power sum form of a polynomial is:
%
%      p(x) = c(0) + c(1) * x + ... + c(n-1) * x^(n-1) + c(n) * x^(n)
%
%    Because MATLAB doesn't allow 0 indexing, we use an adjusted formula:
%
%      p(x) = c(1) + c(2) * x + ... + c(n) * x^(n-1) + c(n+1) * x^(n)
%
%    The degree of a polynomial is the index of the highest power
%    of X with a nonzero coefficient.
%
%    The degree of a constant polynomial is 0.  The degree of the
%    zero polynomial is debatable, but this routine returns the
%    degree as 0.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 April 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D: the nominal degree.
%
%    real C(D+1): the coefficients of the polynomial.
%
%  Output:
%
%    integer D: the adjusted degree.
%
  while ( 0 < d )

    if ( c(d+1) ~= 0.0 )
      return
    end

    d = d - 1;

  end

  return
end
