List of First N Fibonacci Numbers with Performance
import java.math.BigInteger
def fib: Stream[BigInteger] = {
def tail(h: BigInteger, n: BigInteger): Stream[Long] = h #:: tail(n, h + n)
tail(0, 1)
}
(0 to 30) map(fib(_)) toList
Written by Amr Tamimi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Scala
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#