Skip to content

Instantly share code, notes, and snippets.

@myguidingstar-zz
Created December 11, 2012 09:32
Show Gist options
  • Save myguidingstar-zz/4257315 to your computer and use it in GitHub Desktop.
Save myguidingstar-zz/4257315 to your computer and use it in GitHub Desktop.
(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)))))
@myguidingstar-zz
Copy link
Author

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)))))

@cmpitg
Copy link

cmpitg commented Dec 11, 2012

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