Created
October 2, 2014 04:05
-
-
Save zwang/639a523d1911b73cb59b to your computer and use it in GitHub Desktop.
HackerRank evaluate e^x
This file contains hidden or 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
(dotimes [n (read-string (read-line))] | |
(let [x (read-string (read-line)), | |
ex (fn [x] | |
(inc | |
(reduce + | |
(map #(/ (reduce * (repeat % x)) | |
(reduce * (range 1 (inc %))) | |
) | |
(range 1 10) | |
) | |
) | |
) | |
) | |
] | |
(println | |
(format "%.4f" | |
(float | |
(ex x) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment