I have once wrote a program to calculate pi.
You get tons of random points from (0-1)x(0-1) range. They form a square. You calculate how many of these points are inside circle of center 0,5×0,5 and radius 0,5.
Total points quantity divided by quantity of points inside circle will be an approximation of square area divided by circle area. From this data, we can calculate pi. After enough iterations, we can get pretty nice precision.
Latest Answers