Write a function called mypi which consumes a number that specifies the required accuracy and approximates the value of pi to that accuracy. Use the following algorithm to approximate pi:
Think about a quarter circle inside of a unit square (quarter circle has area pi/4). Pick a random point inside the square. If it is in the quarter circle, you get a "hit", otherwise it's a "miss". The approximate area of the quarter circle will be given by the number of "hits" divided by the number of points chosen.
The function should repeat the process of counting hits and misses until at least 10,000 tries have been made or pi is within the required accuracy. It should return the the estimate for pi.
Best Answer