aboutsummaryrefslogtreecommitdiff
path: root/scheme/001-multiples_of_3_or_5.scm
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2021-07-27 11:37:47 +0200
committerCharles Cabergs <me@cacharle.xyz>2021-07-27 11:37:47 +0200
commit726c5ce4decbcd354aff50d1a486bca8c2fa33c1 (patch)
treee96850f51e63789d6dcba3470de1258ec9a6232b /scheme/001-multiples_of_3_or_5.scm
parenta13cc209e002a72a18c659d22ed39dbd99be2fcd (diff)
downloadproject_euler-726c5ce4decbcd354aff50d1a486bca8c2fa33c1.tar.gz
project_euler-726c5ce4decbcd354aff50d1a486bca8c2fa33c1.tar.bz2
project_euler-726c5ce4decbcd354aff50d1a486bca8c2fa33c1.zip
problem 1 2 in scheme
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)