aboutsummaryrefslogtreecommitdiff
path: root/entries/jyoo980/scala/Fib.scala
blob: f9107b0522732e6ceb4b7f1be8a6385572f54483 (plain) (blame)
1
2
3
4
5
6
def fib(n: Int): Int =
  (0 until n).foldLeft((0, 1)) {
    case ((prev, curr), _) => (curr, prev + curr)
  } match {
    case (n, _) => n
  }