Without any fancy formulas, it is possible to estimate Pi using random numbers.
We can use the Monte Carlo method to estimate Pi. The idea is to generate random X and Y coordinates and see how many of them fall inside the unit circle.
The probability of a point falling inside the unit circle is equal to the area of the circle divided by the area of the square. The area of the circle is Pi * r^2, and the area of the square is (2r)^2. So the probability is Pi/4.
After generating a bunch of random points, we can estimate Pi by dividing the number of points that fall inside the circle by the total number of points multiplied by 4.
Here’s a demonstration of the Monte Carlo method in action:
See, eventually, the points will start to form a circle. The more points you generate, the more accurate the estimate of Pi will be.