Fermat's Library (@fermatslibrary) 's Twitter Profile
Fermat's Library

@fermatslibrary

A platform for illuminating academic papers. We annotate and share a paper every week. Save, annotate and share papers with anyone: fermatslibrary.com/margins

ID: 3511430425

linkhttp://fermatslibrary.com calendar_today10-09-2015 03:54:59

3,3K Tweet

761,761K Followers

4 Following

Fermat's Library (@fermatslibrary) 's Twitter Profile Photo

A short Python program to estimate π: import random def estimate_pi(n): m = 0 for i in range(n): x = random.uniform(0, 1) y = random.uniform(0, 1) if x*x + y*y <= 1: m += 1 return 4 * m / n

A short Python program to estimate π:

import random

def estimate_pi(n):
    m = 0
    for i in range(n):
        x = random.uniform(0, 1)
        y = random.uniform(0, 1)
        if x*x + y*y &lt;= 1:
            m += 1
    return 4 * m / n