Created
September 28, 2015 05:55
-
-
Save kohyama/8e599b2e765ad4256f32 to your computer and use it in GitHub Desktop.
Prime numbers in Clojure
This file contains hidden or 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
(def prime-numbers | |
((fn f [x] | |
(cons x | |
(lazy-seq | |
(f (first | |
(drop-while | |
(fn [n] | |
(some #(zero? (mod n %)) | |
(take-while #(<= (* % %) n) prime-numbers))) | |
(iterate inc (inc x)))))))) | |
2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you.
It's really helping me