function [ n_data, n, fn ] = r8_factorial_log_values ( n_data )

%*****************************************************************************80
%
%% R8_FACTORIAL_LOG_VALUES returns values of log(n!).
%
%  Discussion:
%
%    The function log(n!) can be written as
%
%     log(n!) = sum ( 1 <= i <= n ) log ( i )
%
%    In Mathematica, the function can be evaluated by:
%
%      Log[n!]
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    19 September 2004
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Stephen Wolfram,
%    The Mathematica Book,
%    Fourth Edition,
%    Wolfram Media / Cambridge University Press, 1999.
%
%    Daniel Zwillinger, editor,
%    CRC Standard Mathematical Tables and Formulae,
%    30th Edition,
%    CRC Press, 1996.
%
%  Parameters:
%
%    Input/output, integer N_DATA.  The user sets N_DATA to 0 before the
%    first call.  On each call, the routine increments N_DATA by 1, and
%    returns the corresponding data; when there is no more data, the
%    output value of N_DATA will be 0 again.
%
%    Output, integer N, the argument of the function.
%
%    Output, real FN, the value of the function.
%
  n_max = 27;

  fn_vec = [ ...
     0.0000000000000000E+00, ...
     0.0000000000000000E+00, ...
     0.6931471805599453E+00, ...
     0.1791759469228055E+01, ...
     0.3178053830347946E+01, ...
     0.4787491742782046E+01, ...
     0.6579251212010101E+01, ...
     0.8525161361065414E+01, ...
     0.1060460290274525E+02, ...
     0.1280182748008147E+02, ...
     0.1510441257307552E+02, ...
     0.1750230784587389E+02, ...
     0.1998721449566189E+02, ...
     0.2255216385312342E+02, ...
     0.2519122118273868E+02, ...
     0.2789927138384089E+02, ...
     0.3067186010608067E+02, ...
     0.3350507345013689E+02, ...
     0.3639544520803305E+02, ...
     0.3933988418719949E+02, ...
     0.4233561646075349E+02, ...
     0.5800360522298052E+02, ...
     0.1484777669517730E+03, ...
     0.3637393755555635E+03, ...
     0.6050201058494237E+03, ...
     0.2611330458460156E+04, ...
     0.5912128178488163E+04 ];

  n_vec = [ ...
       0, ...
       1, ...
       2, ...
       3, ...
       4, ...
       5, ...
       6, ...
       7, ...
       8, ...
       9, ...
      10, ...
      11, ...
      12, ...
      13, ...
      14, ...
      15, ...
      16, ...
      17, ...
      18, ...
      19, ...
      20, ...
      25, ...
      50, ...
     100, ...
     150, ...
     500, ...
    1000 ];

  if ( n_data < 0 )
    n_data = 0;
  end

  n_data = n_data + 1;

  if ( n_max < n_data )
    n_data = 0;
    n = 0;
    fn = 0.0;
  else
    n = n_vec(n_data);
    fn = fn_vec(n_data);
  end

  return
end
