Created
January 25, 2011 22:33
-
-
Save jaredcacurak/795838 to your computer and use it in GitHub Desktop.
A Clojure solution for Project Euler - Problem 6
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
| (def whole-numbers (iterate inc 1)) | |
| (defn square [n] (* n n)) | |
| (defn sum-of-squares [n] | |
| (reduce + | |
| (take n | |
| (map square whole-numbers)))) | |
| (defn square-of-sum [n] | |
| (square | |
| (reduce + | |
| (take n whole-numbers)))) | |
| (- (square-of-sum 100) (sum-of-squares 100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment