Skip to content

Instantly share code, notes, and snippets.

@jfacoustic
Created January 1, 2020 19:16
Show Gist options
  • Save jfacoustic/b72dbb0adf9ea85f1cbc32a118c82c72 to your computer and use it in GitHub Desktop.
Save jfacoustic/b72dbb0adf9ea85f1cbc32a118c82c72 to your computer and use it in GitHub Desktop.
Calculates interest in clojure
(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