2017-02-14 16:55:48 -05:00
|
|
|
(defun decrement (n) (- n 1))
|
|
|
|
|
|
|
|
(defun percent (n percent)
|
|
|
|
(cond
|
|
|
|
((> percent 0) (/ (+ (* n percent) 50) 100))
|
2017-02-15 09:29:57 -05:00
|
|
|
(T (/ (- (* n percent) 50) 100))
|
2017-02-14 16:55:48 -05:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun compound-interest (principal rate years)
|
|
|
|
(cond
|
|
|
|
((= years 0) principal)
|
2017-02-15 09:29:57 -05:00
|
|
|
(T (compound-interest (+ principal (percent principal rate))
|
2017-02-14 16:55:48 -05:00
|
|
|
rate
|
|
|
|
(decrement years)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|