Skip to content

Commit

Permalink
Problema 1 - Clojure
Browse files Browse the repository at this point in the history
  • Loading branch information
pbalduino committed Mar 7, 2014
1 parent 8441b7d commit 2e1fb11
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 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)

0 comments on commit 2e1fb11

Please sign in to comment.