(*  r_factorial_log_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the logarithm of the factorial *)
(*    function at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  06 February 2006 *)
(*  Author:  John Burkardt *)

xvec = {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};
fvec = {};
num = Length [ xvec ];

Do [ { x = xvec[[i]], f = Log[x!] ,
fvec = Append [ fvec, f ],
      Print["LogFactorial[",x,"]=",N[f,16]] },{i,1,num,1}]

fileout=OpenWrite["C:\\Documents and Settings\\burkardt\\Desktop\\Misc\\mathematica\\r_factorial_log_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  r_factorial_log_values.txt"];today=DateList[];Write[fileout,"#  Created on ",today];Write[fileout,"#"];
Write[fileout,"#  x  f"];
Write[fileout,"#"];
Do[{x=xvec[[i]];f=fvec[[i]];Write[fileout,x,"  ",N[f,16]]},{i,1,num,1}];Close[fileout];