function perm1_sign_test ( )

%*****************************************************************************80
%
%% perm1_sign_test() tests perm1_sign().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'perm1_sign_test():\n' );
  fprintf ( 1, '  perm1_sign() computes the sign of a permutation of (1,...,N).\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  RANK  SIGN  Permutation\n' );
  fprintf ( 1, '\n' );

  n = 4;
  p = [];
  more = 0;
  rank = 0;

  while ( true )

    [ p, more ] = perm1_lex_next ( n, p, more );
    p_sign = perm1_sign ( n, p );

    if ( ~more )
      break
    end

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

    rank = rank + 1;

  end
 
  return
end
