Skip to content

Instantly share code, notes, and snippets.

@uiur
Created August 28, 2009 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uiur/176885 to your computer and use it in GitHub Desktop.
Save uiur/176885 to your computer and use it in GitHub Desktop.
def monte
x = rand(); y = rand()
if (x * x + y * y) < 1
return 1
else
return 0
end
end
hit = 0
100000.times do
hit += monte
end
puts hit / 100000.0 * 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment