Created
September 28, 2011 22:10
-
-
Save omasanori/1249395 to your computer and use it in GitHub Desktop.
A hobby implementation to calculate prime numbers.
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 prime? | |
"Returns true if x is prime number, false otherwise." | |
[x] | |
(not-any? zero? | |
(map #(rem x %) | |
(range 2 (inc (/ x 2)))))) | |
(defn prime-numbers | |
"Returns a lazy seq of prime numbers." | |
[] | |
(filter prime? (drop 2 (range)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment