transcendental-lisp/lisp/compound-interest.lisp

19 lines
374 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
(compound-interest (+ principal (percent principal rate))
rate
(decrement years)
)
)
)