Skip to content

Instantly share code, notes, and snippets.

@bhenry
Created April 29, 2010 15:57
Show Gist options
  • Save bhenry/383816 to your computer and use it in GitHub Desktop.
Save bhenry/383816 to your computer and use it in GitHub Desktop.
;;problem 2 sum even fibonacci #s up to 4000000
(defn fib-seq []
(let [step (fn [pair]
[(last pair) (+ (first pair) (last pair))])]
(map first (iterate step [0 1]))))
(def fibs (fib-seq))
(apply + (filter even? (take-while #(<= % 4000000) fibs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment