The Monte Carlo method is a way to approximate the value of pi using a combination of random sampling and geometric probability:
Draw a square and inscribe a circle inside it
Randomly scatter a large number of points over the square
Count the number of points that fall inside the circle
Divide the number of points inside the circle by the total number of points scattered
Multiply the result by 4 to estimate the value of pi
The more points you scatter, the more accurate the estimate of pi will be.
he Monte Carlo method is based on the idea that the ratio of the area of the circle to the area of the square is equal to pi divided by 4