Commits

Victor Iacoban committed 4d35b3e

20

Comments (0)

Files changed (2)

src/main/clojure/euler/prob020.clj

+(ns euler.prob020
+  (:use tools.factorial))
+
+(defn euler20 [n]
+  (reduce + (map #(read-string (str %)) (str (factorial n)))))

src/main/clojure/tools/factorial.clj

+(ns tools.factorial)
+
+(defn factorial [n]
+  (loop [m n acc 1M]
+    (if (zero? m) acc (recur (dec m) (* acc m)))))