function a = change_polynomial ( value, target, coin_num )

%*****************************************************************************80
%
%% change_polynomial() solves the change making problem using a polynomial algorithm.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 October 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer VALUE(VALUE_NUM), the value of each coin.
%
%    integer TARGET, the maximum desired sum.
%
%    integer COIN_NUM: the exact number of coins to use.
%
%  Output:
%
%    integer A(1:TARGET+1): A(I+1) is the number of sequences of COIN_NUM
%    coins (respecting order) which total the sum of I.
%
  a = zeros ( target + 1, 1 );

  if ( coin_num <= 0 )
    return
  end

  value_num = length ( value );
  for i = 1 : value_num
    j = value(i);
    a(j+1) = a(j+1) + 1;
  end

  if ( coin_num == 1 )
    return
  end
  
  p = a;
  for i = 2 : coin_num
    a = polynomial_multiply ( a, p );
  end

  return
end
 
