Last Updated: February 25, 2016
·
424
· amrnt

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