Skip to content

Instantly share code, notes, and snippets.

Created April 29, 2011 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/948183 to your computer and use it in GitHub Desktop.
Save anonymous/948183 to your computer and use it in GitHub Desktop.
;; jneira's solution to http://4clojure.com/problem/67
(fn primes [n]
(letfn
[(next-prime
[prs nxt]
(if (empty? (filter #(= 0 (mod nxt %)) prs))
(conj prs nxt)
(recur prs (inc nxt))))]
(->> (iterate
(fn [prs] (next-prime prs (inc (last prs)))) [2])
(take n)
(last))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment