Created
June 5, 2010 14:22
-
-
Save borkdude/426665 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn siever2 [to-sieve sieved end] | |
(if (empty? to-sieve) sieved | |
(let [f (first to-sieve) | |
r (rest to-sieve)] | |
(if (> f (Math/sqrt end)) | |
(into sieved to-sieve) | |
(siever2 (remove #(zero? (mod % f)) r) | |
(conj sieved f) | |
end))))) | |
(dotrace [siever2] (siever2 (range 2 32) [] 31)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment