aboutsummaryrefslogtreecommitdiff
path: root/scheme/001-multiples_of_3_or_5.scm
diff options
context:
space:
mode:
Diffstat (limited to 'scheme/001-multiples_of_3_or_5.scm')
-rw-r--r--scheme/001-multiples_of_3_or_5.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/scheme/001-multiples_of_3_or_5.scm b/scheme/001-multiples_of_3_or_5.scm
new file mode 100644
index 0000000..c329de9
--- /dev/null
+++ b/scheme/001-multiples_of_3_or_5.scm
@@ -0,0 +1,20 @@
+;;;;
+;; Multiples of 3 or 5
+;; Problem 1
+;;
+;; 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.
+;;;;
+
+(load "utils.scm")
+
+(define +top+ 1000)
+
+(define result
+ (sum
+ (filter
+ (lambda (x) (or (= 0 (modulo x 3)) (= 0 (modulo x 5))))
+ (range 1 +top+ 1))))
+
+(display result)