Advertisement
Guest User

cljs gobbling up Naive Pi algorithm and making it work

a guest
May 21st, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn pi [ndepthp]
  2.     (loop [nval 4 ndenom 3 ndepth ndepthp]
  3.         (let [nadd (/ 4 ndenom) faddsub (if (== (mod (bit-shift-right (dec ndenom) 1) 2) 0)(+ nval nadd )(- nval nadd))]
  4.             (if (== ndepth 1)
  5.                  faddsub
  6.                  (recur faddsub (+ 2 ndenom) (dec ndepth))))))
  7.  
  8. (enable-console-print!)
  9. (println "Hello ClojureScript!")
  10. (println (time (pi 50000000)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement