Last active
November 14, 2017 21:43
-
-
Save gallettilance/c9228f0a0d95446f689ddaa793285cff to your computer and use it in GitHub Desktop.
Sieve Of Eratosthenes - Stream of Primes
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 theNats [init] | |
(lazy-seq (cons (+ init 1) (theNats (+ init 1)))) | |
) | |
(defn sieve [nats] | |
(lazy-seq (cons (first nats) (filter (fn [x] (> (mod x (first nats)) 0)) (rest nats))) | |
)) | |
(def thePrimes (sieve (theNats 2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment