Advertisement
Guest User

pi

a guest
May 29th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.12 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. i = 0.0; c = 10000000
  4.  
  5. (0..c).each do |i2| i += 1 if rand**2 + rand**2 <= 1 end
  6.  
  7. puts i*4 / c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement