transcendental-lisp/lisp/compound-interest.lisp

20 lines
385 B
Common Lisp
Raw Normal View History

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