Source

euler / clojure / problem10.clj

Full commit
;; problem10
;; John Paulett - June 8, 2009
;;
;; The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
;; Find the sum of all the primes below two million.

(use '[clojure.contrib.lazy-seqs :only (primes)])

(defn sum-primes [max] 
	(reduce + (for [p primes :while (> max p)] p)))
	
;; tests
(assert (= 17 (sum-primes 10)))

(println (sum-primes 2000000)) 
;; 142913828922