Advertisement
Guest User

Untitled

a guest
Dec 27th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;; mine
  2.  
  3. (defn factorial [n]
  4.   (loop [i 1
  5.          result 1]
  6.   (if (= i n)
  7.     (* result i)
  8.     (recur (inc i) (* result i)))))
  9.  
  10. ;; solution
  11.  
  12. (defn factorial [n]
  13.   (loop [n n
  14.          result 1]
  15.   (if (= 0 n)
  16.     result
  17.     (recur (dec n) (* result n)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement