Skip to content

Instantly share code, notes, and snippets.

@LispyAriaro
Created February 22, 2015 05:35
Show Gist options
  • Save LispyAriaro/37d1ee0face3557cc8f9 to your computer and use it in GitHub Desktop.
Save LispyAriaro/37d1ee0face3557cc8f9 to your computer and use it in GitHub Desktop.
(defn my-fac [num]
(if (zero? num)
1
(reduce * (range 1 (inc num)))))
(defn get-input []
(let [num-tests (read-line)
num-tests-as-num (Integer/parseInt num-tests)
the-test-cases-as-num (for [a-case (range 0 num-tests-as-num)]
(Double/parseDouble (read-line)))
the-Es (for [a-case the-test-cases-as-num]
(reduce + (for [counter (range 0 10)]
(/ (Math/pow a-case counter) (my-fac counter)))))]
(doseq [an-e the-Es]
(println an-e))))
(get-input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment