(*  pi_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the pi *)
(*    function at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  03 February 2006 *)
(*  Author:  John Burkardt *)

nvec = {10,20,30,40,50,60,70,80,90,100,1000,10000,100000,1000000,10000000,100000000,1000000000};
fvec = {};
num = Length [ nvec ];

Do[{ n = nvec[[i]], f = PrimePi[n],
fvec = Append [ fvec, f ],
Print["Pi[",n,"]=",f]
}, {i, 1, num,1}]

fileout=OpenWrite["C:\\Documents and Settings\\burkardt\\Desktop\\Misc\\mathematica\\pi_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  pi_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,"  ",f]},{i,1,num,1}];Close[fileout];