(*  i_factorial_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the factorial *)
(*    function at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  23 January 2006 *)
(*  Author:  John Burkardt *)

nvec = {};
Do [ {  
n = i, 
nvec = Append [ nvec, n],
}, {i,0,12,1} ]
num = Length [ nvec ];
fvec = {};

Do [ { n = nvec[[i]], f = n! ,
fvec = Append [ fvec, f],
      Print["Factorial[",n,"]=",N[f,16]] },{i,1,num,1}]

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