Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created May 29, 2009 21:50
Show Gist options
  • Save tebeka/120234 to your computer and use it in GitHub Desktop.
Save tebeka/120234 to your computer and use it in GitHub Desktop.
#!/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