Created
January 1, 2020 19:16
-
-
Save jfacoustic/b72dbb0adf9ea85f1cbc32a118c82c72 to your computer and use it in GitHub Desktop.
Calculates interest in clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn calculate-interest | |
[apy base deposit months] | |
(if (= months 0) | |
( + base (* base apy)) | |
(do (def newBase (+ base deposit)) | |
(if (= (mod months 12) 0) | |
(calculate-interest apy (+ newBase (* newBase apy)) deposit (dec months)) | |
(calculate-interest apy newBase deposit (dec months)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment