The Weak Reference

The Weak Reference

Kurser i Domain-Driven Design - Våren 2012


Missa inte min nästa kurs i Domändriven Design!


Domain-Driven Design: Domänmodellen i arbete 11-14 juni, Stockholm



Monday, September 21, 2009

Geeky Fact of the Day

I read this tweet by Joshua Bloch:

"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)))

0 comments: