I programmed Lucky Numbers in Clojure: (defn indexed-sieve [index this-list] (keep-indexed (fn [i v] (if (= 0 (mod (inc i) index)) nil v)) this-list))
(defn lucky-numbers [max-value] (let [current-list (atom (indexed-sieve 2 (range 1 max-value))) current-index (atom 1)] (while (< @current-index (count @current-list)) (reset! current-list (indexed-sieve (nth @current-list @current-index) @current-list)) (reset! current-index (inc @current-index))) current-list)) It is short, but is it good? For a large max-value it takes 'some' time. (time (def lucky (lucky-numbers 1000000))) "Elapsed time: 790832.407467 msecs" #'user/lucky -- Cecil Westerhof -- 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.