transcendental-lisp/lisp/compound-interest.lisp

20 lines
385 B
Common Lisp

(defun decrement (n) (- n 1))
(defun percent (n percentage)
(if (> percentage 0)
(/ (+ (* n percentage) 50) 100)
(/ (- (* n percentage) 50) 100)
)
)
(defun compound-interest (principal interest-rate years)
(if (< years 1)
principal
(compound-interest
(+ principal (percent principal interest-rate))
interest-rate
(decrement years)
)
)
)