Created
May 19, 2012 05:03
-
-
Save fumokmm/2729276 to your computer and use it in GitHub Desktop.
エラトステネスの篩を使って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
(defn sieve [nums] | |
(filter #(not= 0 (rem % (first nums))) (rest nums))) | |
(defn primes [] | |
(map first | |
(iterate sieve (iterate inc 2)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment