transcendental-lisp/lisp/compound-interest.lisp

21 lines
347 B
Common Lisp
Raw Normal View History

(defun decrement (n) (- n 1))
(defun percent (n percent)
(if (> percent 0)
(/ (+ (* n percent) 50) 100)
(/ (- (* n percent) 50) 100)
)
)
(defun compound-interest (principal rate years)
(if (= years 0)
principal
2017-03-03 15:06:49 -05:00
(compound-interest
(+ principal (percent principal rate))
rate
(decrement years)
)
)
)
2017-03-03 15:06:49 -05:00