Guest User

fact in clojure

a guest
Jan 30th, 2011
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.15 KB | None | 0 0
  1. (defn fact3 [x]
  2.   (let [f (fn [x ans] (if (= x 0) ans (recur (dec x) (* x ans))))]
  3.     (f x 1)))
  4.  
  5. (defn fact4 [x]
  6.   (reduce * (range 1 (inc x))))
Advertisement
Add Comment
Please, Sign In to add comment