Skip to content

Commit 29912d0

Browse files
author
Michael Bentley
committed
clearer without the extra lines
1 parent 9363c5c commit 29912d0

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

problem-001.lisp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,20 @@
22

33
(defun problem-001 ()
44
"Returns the sum of multiples of 3 and 5 that are less than 1000"
5-
(- (+ (sum-of-integers-below 1000
6-
:that-are-multiples-of 3)
7-
(sum-of-integers-below 1000
8-
:that-are-multiples-of 5))
9-
(sum-of-integers-below 1000
10-
:that-are-multiples-of 15)))
5+
(- (+ (sum-of-integers-below 1000 :that-are-multiples-of 3)
6+
(sum-of-integers-below 1000 :that-are-multiples-of 5))
7+
(sum-of-integers-below 1000 :that-are-multiples-of 15)))
118

129

1310

1411
(defun sum-of-integers-below (limit &key (that-are-multiples-of 1))
1512
"Returns the sum of multiples below limit."
1613
(let ((mult that-are-multiples-of))
17-
(assert (and (integerp limit)
18-
(integerp mult))
14+
(assert (and (integerp limit) (integerp mult))
1915
(limit mult))
2016
(* mult
21-
(/ (* (floor (1- limit)
22-
mult)
23-
(1+ (floor (1- limit)
24-
mult)))
17+
(/ (* (floor (1- limit) mult)
18+
(1+ (floor (1- limit) mult)))
2519
2))))
2620

2721

0 commit comments

Comments
 (0)