joaguilar joaguilar

View pi.rb
1 2 3 4 5 6 7 8 9
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}"
 
Something went wrong with that request. Please try again.