one-file-projects/primefactors.clj

13 lines
170 B
Clojure
Raw Permalink Normal View History

2016-08-04 19:41:56 +02:00
(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)
)
)
)