Sha256: 1abbbad52f6fbbf8b05d5d7ffd6610810d4c518ed7ea7a953d2692b98b3fa18b
Contents?: true
Size: 684 Bytes
Versions: 396
Compression:
Stored size: 684 Bytes
Contents
(ns sieve) (defn sieve "Returns a list of primes less than or equal to limit" [limit] (loop [current-sieve (concat [false false] (range 2 (inc limit))) last-prime 1] (let [current-prime (->> current-sieve (drop (inc last-prime)) (some identity))] (if current-prime (recur (map #(and %1 %2) (concat (repeat (inc current-prime) true) (cycle (concat (repeat (dec current-prime) true) [false]))) current-sieve) current-prime) (filter identity current-sieve)))))
Version data entries
396 entries across 396 versions & 1 rubygems