Skip to content

Instantly share code, notes, and snippets.

View joaguilar's full-sized avatar

Jose Alberto Aguilar joaguilar

View GitHub Profile
@joaguilar
joaguilar / pi.rb
Created February 23, 2012 04:56
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}"