pi.montecarlo <- function(n){ mean(replicate(n, sum(runif(2)^2) < 1)) * 4 }