3 ms·
A pretty fast way in Haskell/ghci[0] is: λ: fibs = 1 : 1 : zipWith (+) fibs (tail fibs) λ: last $ take 47 fibs 2971215073 [0]: https://wiki.haskell.org/The_Fi
by BooneJS 8y ago
A pretty fast way in Haskell/ghci[0] is:
λ: fibs = 1 : 1 : zipWith (+) fibs (tail fibs)
λ: last $ take 47 fibs
2971215073
[0]: https://wiki.haskell.org/The_Fibonacci_sequence#Canonical_zipWith_implementation https://wiki.haskell.org/The_Fibonacci_sequence#Canonical_zi...
- st1ck 8y agoIt got mingled without newlines (and "λ:" prompt doesn't help readability). In one line: let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in fibs !! 47 Shorter but less readable: fix (scanl (+) 0 . (1:)) !! 47