diff --git a/001/clojure/euler001.clj b/001/clojure/euler001.clj new file mode 100644 index 0000000..004ba09 --- /dev/null +++ b/001/clojure/euler001.clj @@ -0,0 +1,21 @@ +(ns euler001) + +; Problem 1 - Multiples of 3 and 5 +; +; 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 by-n [n] + (fn [x] + (= 0 (mod x n)))) + +(def by-3 (by-n 3)) +(def by-5 (by-n 5)) + +(defn multiples [] + (reduce + + (filter #(or (by-3 %) + (by-5 %)) + (range 1 1001)))) + +(multiples) \ No newline at end of file