**Christophe Grand**:

(def fib-seq

(lazy-cat [0 1] (map + fib-seq (rest fib-seq))))

Be sure to specify how many numbers you want or it will run forever:

(take 10 fib-seq)

skip to main |
skip to sidebar
## Monday, January 5, 2009

###
Short Fibonacci Function

I think this is one of the shortest Fibonacci sequences I've ever seen. It's interesting to see the sequence defined as a recursive definition. It was written in Clojure by **Christophe Grand**:

Be sure to specify how many numbers you want or it will run forever:

(take 10 fib-seq)

(def fib-seq

(lazy-cat [0 1] (map + fib-seq (rest fib-seq))))

Be sure to specify how many numbers you want or it will run forever:

(take 10 fib-seq)

Subscribe to:
Posts (Atom)