Created
May 2, 2020 04:57
-
-
Save johnwesonga/aadedbca5b89f95df94625b827a5c0f6 to your computer and use it in GitHub Desktop.
Factorial in Clojure
This file contains hidden or 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
(defn fact | |
[x] | |
(cond | |
(zero? x) 1 | |
(= x 1) 1 | |
:else (* x (fact (dec x))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment