Created
February 23, 2012 04:56
-
-
Save joaguilar/1890381 to your computer and use it in GitHub Desktop.
Jose Aguilar's solution to the Los Angeles Coding Dojo Feb. 22nd, 2012
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pointsinsidecircle = 0.0 | |
1000000.times do | |
if Math.sqrt((rand-0.5)**2 + (rand-0.5)**2) <= 0.5 | |
pointsinsidecircle += 1 | |
end | |
end | |
puts "Value of pi=#{(pointsinsidecircle/1000000.0)*4.0}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment