Guest User

Untitled

a guest
Sep 19th, 2010
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. (def throws 10)
  2. (def hits 0.0)
  3.  
  4. ;(dorun (for [i (range 0 5)](
  5.  
  6. (def x (rand))
  7. (def y (rand))
  8. (def Rsquared (+ (* (- 0.5 x) (- 0.5 x)) (* (- 0.5 y) (- 0.5 y)) ) )
  9. (println Rsquared)
  10. (if (< Rsquared 0.25) (def hits (+ hits 1)))
  11.  
  12. ;))))
  13. (def pi (* 4 (/ hits throws)) )
  14.  
  15. (println pi)
Advertisement
Add Comment
Please, Sign In to add comment