Created
April 29, 2011 17:43
-
-
Save anonymous/948680 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
;; jneira's solution to http://4clojure.com/problem/67 | |
(fn primes3 [n] | |
(let | |
[next-prime | |
(fn [prs] | |
(letfn | |
[(aux [[f & r :as c] nxt] | |
(println c nxt) | |
(cond | |
(empty? c) (conj prs nxt) | |
(zero? (mod nxt f)) (recur prs (inc nxt)) | |
:else (recur (take-while #(< % (quot nxt f)) r) | |
nxt)))] | |
(aux prs (inc (last prs)))))] | |
(->> (iterate next-prime [2]) | |
(take n) | |
(last)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment