Skip to content

Instantly share code, notes, and snippets.

@pingles
Created October 20, 2010 15:49
Show Gist options
  • Save pingles/636674 to your computer and use it in GitHub Desktop.
Save pingles/636674 to your computer and use it in GitHub Desktop.
(defn primes
[n]
(letfn [(multiple-of?
[p]
(= 0
(mod n p)))
(sieve
[ps]
(let [p (first (rest ps))]
(if (> (* p p)
n)
ps
(recur (remove #(multiple-of? %)
ps)))))]
(sieve (range 2 (+ n 1)))))
(primes 30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment