[ create a new paste ] login | about

Link: http://codepad.org/9kat4v5V    [ raw code | output | fork ]

swapnilghorpade - Python, pasted on Dec 1:
1
2
3
4
5
6
7
8
9
import random
import math

count_inside = 0
for count in range(0, 10000):
    d = math.hypot(random.random(), random.random())
    if d < 1: count_inside += 1
count += 1
print 4.0 * count_inside / count


Output:
1
3.1536


Create a new paste based on this one


Comments: