Source

euler / clojure / problem1.clj

Full commit
;; problem1
;; John Paulett - June 6, 2009
;;
;; If we list all the natural numbers below 10 that are multiples of 3 or 5, we
;; get 3, 5, 6 and 9. The sum of these multiples is 23.
;; Find the sum of all the multiples of 3 or 5 below 1000.

(defn mod? [num div] (= 0 (mod num div)))
(defn mod3or5? [num] (or (mod? num 3) (mod? num 5)))
(defn prob1 [max] (reduce + (filter mod3or5? (range 0 max))))

(assert (= 23 (prob1 10)))
println (prob1 1000)