2017-02-14 16:55:48 -05:00
|
|
|
(defun decrement (n) (- n 1))
|
|
|
|
|
2017-03-06 11:00:18 -05:00
|
|
|
(defun percent-of-number (n percentage)
|
2017-03-04 16:33:05 -05:00
|
|
|
(if (> percentage 0)
|
|
|
|
(/ (+ (* n percentage) 50) 100)
|
2017-03-06 11:00:18 -05:00
|
|
|
(/ (- (* n percentage) 50) 100)))
|
2017-02-14 16:55:48 -05:00
|
|
|
|
2017-03-04 16:33:05 -05:00
|
|
|
(defun compound-interest (principal interest-rate years)
|
|
|
|
(if (< years 1)
|
2017-02-27 15:36:17 -05:00
|
|
|
principal
|
2017-03-03 15:06:49 -05:00
|
|
|
(compound-interest
|
2017-03-06 11:00:18 -05:00
|
|
|
(+ principal (percent-of-number principal interest-rate))
|
2017-03-04 16:33:05 -05:00
|
|
|
interest-rate
|
2017-03-06 11:00:18 -05:00
|
|
|
(decrement years))))
|