Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fib(n: Int): Int = {
- def go(first: Int, second: Int, iteration: Int): Int = iteration match {
- case _ if iteration == n => first + second
- case _ => go(second, first + second, iteration + 1)
- }
- go(0, 1, 1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement