Created
December 11, 2012 09:32
-
-
Save myguidingstar-zz/4257315 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
(defn fact [n] | |
(loop [n n x (dec n)] | |
(if (= 1 x) | |
n | |
(recur (* n x) (dec x))))) | |
(apply + (->> (bigint 100) | |
fact | |
str | |
(map #(Integer. (str %1))))) |
Beautified version:
(defn fact [n]
(loop [n n
x (dec n)]
(if (= 1 x)
n
(recur (* n x) (dec x)))))
(apply + (->> (bigint 100)
fact
str
(map #(Integer. (str %)))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
beautified version
(defn fact [n](loop [n n x %28dec n%29]
%28if %28= 1 x%29
n
%28recur %28* n x%29 %28dec x%29%29%29))
(apply + (->> (bigint 100)
fact
str
(map #(Integer. (str %1)))))