Prime factorization in clojure.

This commit is contained in:
madmaurice 2016-08-04 19:41:56 +02:00
parent 11b5c8d5ca
commit aece5b5da4

13
primefactors.clj Normal file
View file

@ -0,0 +1,13 @@
(defn factors [x]
(if (== x 1)
'()
(let [f
(first
(filter (fn [e] (zero? (mod x e)))
(range 2 (+ x 1))
)
)]
(conj (factors (/ x f)) f)
)
)
)