function n = polynomial_degree ( c )

%*****************************************************************************80
%
%% polynomial_degree() returns the degree of a polynomial.
%
%  Discussion:
%
%    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:
%
%    15 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer C(), the coefficients of the polynomial.
%
%  Output:
%
%    integer DEGREE, the degree of the polynomial.
%
  n = length ( c ) - 1;

  while ( 0 < n )

    if ( c(n+1) ~= 0 )
      return
    end

    n = n - 1;

  end

  return
end
