Monte Carlo methods: Difference between revisions

Content added Content deleted
(Added solution for EDSAC)
Line 1,022: Line 1,022:


=={{header|EasyLang}}==
=={{header|EasyLang}}==
<syntaxhighlight lang="text">func mc n . .
<syntaxhighlight lang="text">
proc mc n . .
for i range n
x = randomf
for i = 1 to n
y = randomf
x = randomf
if x * x + y * y < 1
y = randomf
hit += 1
if x * x + y * y < 1
.
hit += 1
.
.
.
print 4.0 * hit / n
print 4.0 * hit / n
.
.
numfmt 4 0
fscale 4
call mc 10000
call mc 10000
call mc 100000
call mc 100000
call mc 1000000
call mc 1000000
call mc 10000000</syntaxhighlight>
call mc 10000000
</syntaxhighlight>
Output:
Output:
3.1292
3.1292