Created
May 29, 2009 21:50
-
-
Save tebeka/120234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env clojure | |
; vim:ft=clojure | |
(defn fact [n] | |
(loop [n n f 1] | |
(if (= n 1) | |
f | |
(recur (dec n) (* f n))))) | |
(if (not= (count *command-line-args*) 1) | |
(println "usage: fact.clj NUMBER") | |
(let [n (Integer/parseInt (first *command-line-args*))] | |
(println (fact n)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment