Skip to content
This repository
tree: 9277dc8e77
Fetching contributors…

Cannot retrieve contributors at this time

file 19 lines (15 sloc) 0.362 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
(ns clojure.examples.factorial)

(defn fact [x]
    (loop [n x f 1]
        (if (= n 1)
            f
            (recur (dec n) (* f n)))))

(defn test [times]
    (loop [rem times]
        (if (> rem 0)
            (do (fact 20)
                (recur (dec rem))))))

;; on my machine
;; clojure jvm : 25 sec
;; clojure pypy : 48 sec

(time (test 19999999))
Something went wrong with that request. Please try again.