2015-02-18 16:31 GMT+01:00 Tassilo Horn <t...@gnu.org>: > Here's my version: > > --8<---------------cut here---------------start------------->8--- > (defn drop-every-nth [c n] > (keep-indexed (fn [i el] > (if (zero? (mod (inc i) n)) nil el)) > c)) > > (defn lucky-numbers [n] > (loop [c (range 1 (inc n) 2), survivor-idx 1] > (let [i (nth c survivor-idx)] > (if (> (count c) i) > (recur (drop-every-nth c i) (inc survivor-idx)) > c)))) > --8<---------------cut here---------------end--------------->8--- >
By the way: it goes wrong for values below 3. -- 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.