2017-02-14 16:55:48 -05:00
|
|
|
(defun decrement (n) (- n 1))
|
|
|
|
|
|
|
|
(defun percent (n percent)
|
2017-02-27 15:36:17 -05:00
|
|
|
(if (> percent 0)
|
|
|
|
(/ (+ (* n percent) 50) 100)
|
|
|
|
(/ (- (* n percent) 50) 100)
|
2017-02-14 16:55:48 -05:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun compound-interest (principal rate years)
|
2017-02-27 15:36:17 -05:00
|
|
|
(if (= years 0)
|
|
|
|
principal
|
|
|
|
(compound-interest (+ principal (percent principal rate))
|
|
|
|
rate
|
|
|
|
(decrement years)
|
2017-02-14 16:55:48 -05:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|