|
|
|
|
|
by crntaylor
4753 days ago
|
|
I can't resist a quick plug for this beautiful O(n) implementation of the fibonacci sequence in Haskell. One line to define the list `fibs` -- an infinite list of fibonacci numbers -- and one line to define the function `fib` which simply takes the n'th element of the list. λ> let fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
λ> let fib n = fibs!!n
λ> fib 100
354224848179261915075
|
|