Monte Carlo methods: Difference between revisions

no edit summary
m (→‎{{header|REXX}}: added/changed whitespace and comments.)
No edit summary
Line 249:
3.142828
3.141679
</pre>
 
=={{header|BASIC256}}==
{{works with|basic256|1.1.4.0}}
<lang basic>
# Monte Carlo Simulator
# Determine value of pi
# 21010513
 
 
tosses = 1000
in_c = 0
i = 0
 
for i = 1 to tosses
x = rand
y = rand
x2 = x * x
y2 = y * y
xy = x2 + y2
d_xy = sqr(xy)
if d_xy <= 1 then
in_c += 1
endif
next i
 
print float(4*in_c/tosses)</lang>
{{out}}
<pre>
Throws Result
1000 3.208
10000 3.142
20000 3.1388
40000 3.1452
</pre>
 
Anonymous user