14 lines
246 B
Text
14 lines
246 B
Text
|
|
for pow = 2 to 6
|
||
|
|
n = 10 ^ pow
|
||
|
|
print n; chr$(9); getPi(n)
|
||
|
|
next
|
||
|
|
end
|
||
|
|
|
||
|
|
function getPi(n)
|
||
|
|
incircle = 0
|
||
|
|
for throws = 0 to n
|
||
|
|
incircle = incircle + (rnd(1)^2 + rnd(1)^2 < 1)
|
||
|
|
next
|
||
|
|
getPi = 4 * incircle / throws
|
||
|
|
end function
|