calculates pi using the monte carlo method