Skip to content

Instantly share code, notes, and snippets.

@bluven
Created May 4, 2014 14:02
Show Gist options
  • Save bluven/339902c60e6e799f2897 to your computer and use it in GitHub Desktop.
Save bluven/339902c60e6e799f2897 to your computer and use it in GitHub Desktop.
计算某数值以下的偶数fib和
(def fib-seq
(lazy-cat [0 1] (map + (rest fib-seq) fib-seq)))
(def even-fib-seq (filter even? fib-seq))
(defn sum-fib [limit]
(loop [i 1
fib-num (nth even-fib-seq i)
seqn []]
(if (>= fib-num limit)
(apply + seqn)
(recur (inc i) (nth even-fib-seq (inc i)) (cons fib-num seqn )))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment