function collatz_polynomial_sequence ( p )

%*****************************************************************************80
%
%% collatz_polynomial_sequence() prints a Collatz polynomial sequence.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    John D Cook,
%    Polynomial analog of the Collatz conjecture,
%    27 July 2021,
%    https://www.johndcook.com/blog/2021/07/27/polynomial-collatz/
%    
%  Input:
%
%    integer P(), the initial polynomial.
%
  i = 0;

  while ( true )    
    fprintf ( 1, '%d: ', i )
    polynomial_print ( p );
    if ( length ( p ) == 1 )
      break
    end
    p = collatz_polynomial_next ( p );
    i = i + 1;
  end

  return
end
