func Point() (x, y float64) { for { // This loop runs 4/π times on average. x = 2*rand.Float64() - 1 y = 2*rand.Float64() - 1 if x*x+y*y < 1 { return } } }
def Point(): i = 0 while i < math.pi * 4: x = 2 * random.uniform(0,1) - 1 y = 2 * random.uniform(0,1) - 1 if x*x + y*y < 1: return x, y i += 1 Point()