Got it down to still very slow 100 seconds by using the vec function on the sieved result to make it a vector instead of a linked list. This way the nth call inside the recur statement is way faster.
vec
nth
recur
(defn luckies [n] (loop [working-set (range 1 (inc n)) ln 2 step 1] (if (< ln (count working-set)) (let [new-ws (vec (keep-indexed (fn [ix item] (when (not= 0 (mod (inc ix) ln)) item)) working-set))] (recur new-ws (nth new-ws step) (inc step))) (println (count working-set)))))
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Got it down to still very slow 100 seconds by using the
vec
function on the sieved result to make it a vector instead of a linked list. This way thenth
call inside therecur
statement is way faster.