"Geeky fact of the day: the sum of the first n cubes equals the square
of the sum of the first n integers"
And decide to throw some Clojure at it:
(use 'clojure.contrib.math)
(defn geeky-fact [n]
(=
(reduce + (map #(expt % 3) (take n (iterate inc 1))))
(expt (reduce + (take n (iterate inc 1))) 2)))
No comments:
Post a Comment