Skip to content

Instantly share code, notes, and snippets.

@jergason
Created November 6, 2014 16:50
Show Gist options
  • Save jergason/8e21861ab232acd6909a to your computer and use it in GitHub Desktop.
Save jergason/8e21861ab232acd6909a to your computer and use it in GitHub Desktop.
(defn products-of-ints [nums]
"Takes an array of integers and returns an array of integers where the
element at each index is the product of all the other elements except the
element at that index multiplied."
(let [product-of-every-num (reduce * nums)]
(map #(/ product-of-every-num %) nums)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment