Jump to content

Monte Carlo methods: Difference between revisions

(Added solution for EDSAC)
Line 1,022:
 
=={{header|EasyLang}}==
<syntaxhighlight lang="text">func mc n . .
proc mc n . .
for i range n
for xi = randomf1 to n
y x = randomf
if x * x + y * y <= 1randomf
hitif x * x += y * y < 1
. hit += 1
.
.
print 4.0 * hit / n
.
numfmt 4 0
fscale 4
call mc 10000
call mc 100000
call mc 1000000
call mc 10000000</syntaxhighlight>
</syntaxhighlight>
Output:
3.1292
2,063

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.