Skip to content

Commit

Permalink
clojure problem 007
Browse files Browse the repository at this point in the history
  • Loading branch information
yvern committed Jun 13, 2018
1 parent e43606f commit f77de4c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/007/p007.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; works in both clojure and clojurescript

(defn next-primes [[primes new]]
(let [new* (inc (inc new))]
(if (some #(= 0 (rem new %)) primes)
[primes new*]
[(conj primes new) new*])))

(defn solve []
(let [primes (->> [[2] 3]
(iterate next-primes)
(map first)
dedupe
(map peek))]
(first (drop 10000 primes))))

(prn (solve))

0 comments on commit f77de4c

Please sign in to comment.