(defn not-divisible-by?[num denum] (not (= (mod num denum) 0))) (defn div-nums [denum bound] (for [x (range 2 bound) :when (not-divisible-by? x denum)] x))
(defn divisible? [coll denum] (empty? (filter #(and (not= denum %) (not(not-divisible-by? denum %))) coll))) (defn generate-primes "Sieve of Eratosthenes" [n] (let [src (div-nums 2 n)] (cons 2 (for [x src :when (divisible? src x)] x)))) -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.