FUNCTION getpi(throws) LET incircle = 0 FOR i = 1 to throws !a square with a side of length 2 centered at 0 has !x and y range of -1 to 1 LET randx = (rnd*2)-1 !range -1 to 1 LET randy = (rnd*2)-1 !range -1 to 1 !distance from (0,0) = sqrt((x-0)^2+(y-0)^2) LET dist = sqr(randx^2+randy^2) IF dist < 1 then !circle with diameter of 2 has radius of 1 LET incircle = incircle+1 END IF NEXT i LET getpi = 4*incircle/throws END FUNCTION CLEAR PRINT getpi(10000) PRINT getpi(100000) PRINT getpi(1000000) PRINT getpi(10000000) END