function value = i4_factorial_log ( n )

%*****************************************************************************80
%
%% i4_factorial_log() returns the logarithm of N factorial.
%
%  Discussion:
%
%    N! = Product ( 1 <= I <= N ) I
%
%    N! = Gamma(N+1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 March 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the argument of the function.
%    0 <= N.
%
%  Output:
%
%    real VALUE, the logarithm of N factorial.
%
  if ( n < 0 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'I4_FACTORIAL_LOG - Fatal error!\n' );
    fprintf ( 1, '  N < 0.\n' );
    error ( 'I4_FACTORIAL_LOG - Fatal error!' );
  end

  value = 0.0;

  for i = 2 : n
    value = value + log ( i );
  end

  return
end
