function perm1_next3_test ( )

%*****************************************************************************80
%
%% PERM1_NEXT3_TEST tests PERM1_NEXT3.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    09 November 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'PERM1_NEXT3_TEST\n' );
  fprintf ( 1, '  PERM1_NEXT3 generates permutations of (1,...,N).\n' );
  fprintf ( 1, '\n' );

  n = 4;
  p = [];
  more = false;
  rank = 0;
 
  while ( true )

    [ p, more, rank ] = perm1_next3 ( n, p, more, rank );

    if ( ~ more )
      break
    end

    fprintf ( 1, '  %3d:', rank );
    for i = 1 : n
      fprintf( 1, ' %2d', p(i) );
    end
    fprintf ( 1, '\n' );

  end

  return
end
