RosettaCodeData/Task/Monte-Carlo-methods/BASIC256/monte-carlo-methods-1.basic
2023-07-01 13:44:08 -04:00

22 lines
297 B
Text

# 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)