Skip to content

Instantly share code, notes, and snippets.

@joaguilar
Created February 23, 2012 04:56
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 joaguilar/1890381 to your computer and use it in GitHub Desktop.
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
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