From 726c5ce4decbcd354aff50d1a486bca8c2fa33c1 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 27 Jul 2021 11:37:47 +0200 Subject: problem 1 2 in scheme --- scheme/001-multiples_of_3_or_5.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scheme/001-multiples_of_3_or_5.scm (limited to 'scheme/001-multiples_of_3_or_5.scm') 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) -- cgit