Advertisement
Guest User

Untitled

a guest
Jan 30th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.19 KB | None | 0 0
  1. (defn fact [x]
  2.   (loop [n x
  3.          ans 1]
  4.   (if (= n 0)
  5.     ans
  6.     (recur (dec n) (* n ans)))))
  7.  
  8. (defn fact2
  9.   ([x] (fact2 x 1))
  10.   ([x ans] (if (= x 0) ans (recur (dec x) (* x ans)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement