Skip to content

Instantly share code, notes, and snippets.

@Steffo99
Created October 19, 2015 14:46
Show Gist options
  • Save Steffo99/649c854e899f5ce841c4 to your computer and use it in GitHub Desktop.
Save Steffo99/649c854e899f5ce841c4 to your computer and use it in GitHub Desktop.
import random
import math
random.seed()
sqm = 0
for prova in range(0, 5):
inside = 0
for granello in range(0, 1000000):
x = random.random()
y = random.random()
if(x*x + y*y <= 1):
inside = inside + 1;
pi = inside / 1000000 * 4
print(pi)
scarto = abs(3.1415926535 - pi)
sqm = sqm + scarto*scarto
print(sqm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment