16 lines
328 B
Text
16 lines
328 B
Text
go =>
|
|
foreach(N in 0..7)
|
|
sim_pi(10**N)
|
|
end,
|
|
nl.
|
|
|
|
% The specific pi simulation
|
|
sim_pi(N) =>
|
|
Inside = sim(N,pi_f),
|
|
MyPi = 4.0*Inside/N,
|
|
Pi = math.pi,
|
|
println([n=N, myPi=MyPi, diff=Pi-MyPi]).
|
|
|
|
% The simulation function:
|
|
% returns 1 if success, 0 otherwise
|
|
pi_f() = cond(frand()**2 + frand()**2 <= 1, 1, 0).
|