I looked through some of my Project Euler solutions and found this version. It is essentially the same as Uncle Bob's, but to my eye it is a bit easier to read.
(defn least-nontrivial-divisor [n] ;; integer n > 1 (loop [k 2] (cond (zero? (rem n k)) k ;; k divides n, return k (> (* k k) n ) n ;; k > sqrt n, return n :else (recur (inc k))))) (defn prime-factors [n] ;; integer n > 1 (loop [n n factors []] (if (= 1 n) factors (let [d (least-nontrivial-divisor n)] (recur (quot n d) (conj factors d)))))) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en