File tree 1 file changed +6
-12
lines changed 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 2
2
3
3
(defun problem-001 ()
4
4
" 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 )))
11
8
12
9
13
10
14
11
(defun sum-of-integers-below (limit &key (that-are-multiples-of 1 ))
15
12
" Returns the sum of multiples below limit."
16
13
(let ((mult that-are-multiples-of))
17
- (assert (and (integerp limit)
18
- (integerp mult))
14
+ (assert (and (integerp limit) (integerp mult))
19
15
(limit mult))
20
16
(* 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)))
25
19
2 ))))
26
20
27
21
You can’t perform that action at this time.
0 commit comments