Created
February 26, 2021 15:01
-
-
Save fernandrone/fb51536e7aa90788eb8d7337c5d237a1 to your computer and use it in GitHub Desktop.
Clojure exponential/power function.
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 pow [x n] | |
"x^n" | |
(if (>= n 0) | |
(->> x (repeat n) (reduce *)) | |
(->> (pow (/ 1 x) (- n))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment