Last active
August 29, 2015 14:23
-
-
Save uroybd/c5c980e6de998cb7aa30 to your computer and use it in GitHub Desktop.
Hackerrank e^x
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
(loop [test-case-remaining (Integer/parseInt (read-line))] | |
(while (not= 0 test-case-remaining) | |
(do (println (let [factorial (fn [n] | |
(reduce * (take n (range 1 (inc n))))) | |
to-the-power (fn [n m] | |
(reduce * (repeat m n))) | |
e-to-the-power-x (fn [x] | |
(inc (apply + (map #(float (/ (to-the-power x %) | |
(factorial %))) | |
(range 1 10)))))] | |
(e-to-the-power-x (Float/parseFloat (read-line))))) | |
(dec test-case-remaining)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment