Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; mine
- (defn factorial [n]
- (loop [i 1
- result 1]
- (if (= i n)
- (* result i)
- (recur (inc i) (* result i)))))
- ;; solution
- (defn factorial [n]
- (loop [n n
- result 1]
- (if (= 0 n)
- result
- (recur (dec n) (* result n)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement