RosettaCodeData/Task/Monte-Carlo-methods/BASIC256/monte-carlo-methods-1.basic

23 lines
297 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
# 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)