Skip to content

Instantly share code, notes, and snippets.

@thiagofm
Created October 9, 2012 23:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagofm/3862014 to your computer and use it in GitHub Desktop.
Save thiagofm/3862014 to your computer and use it in GitHub Desktop.
2.clj
(ns problem2.core)
(defn fib-rec
[ list-fib n ]
(if
(< (last list-fib) 4000000)
(fib-rec (conj list-fib (reduce + (take-last 2 list-fib))) (- n 1)) list-fib)
)
(defn fib
[ n ]
(fib-rec [0 1] n)
)
(defn sum-even
[ list-sum ]
(reduce + (filter even? list-sum))
)
(defn -main
[& args]
(sum-even (fib 10))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment