Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Problema 1 - Clojure

  • Loading branch information...
commit 2e1fb11fa6f959cc49e21b88ade9cd34572b7ed1 1 parent 8441b7d
@pbalduino authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 001/clojure/euler001.clj
View
21 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)
Please sign in to comment.
Something went wrong with that request. Please try again.