Estimates pi using the Monte Carlo method. Each iteration selects a new random point in the square. The point is colored purple if it is within the circle (the distance from 0,0 <= radius). The area of the square is: (2 * radius)^2 and the area of the circle is Pi * radius^2 The expected ratio of points in the circle to the total number of points is (Pi * radius^2) / (2 * radius)^2. The radius ^2 cancels out. The program calculates an actual ratio of points inside and outside the circle. So we get another formula: Pi / 4 = inCircle / totalPoints If you use algebra to solve for Pi, the equation becomes Pi = 4*inCircle / totalPoints. You might want to try turbo mode. The accuracy of the calculation is related to how random the numbers are.
My dad wrote this.