Last active
September 8, 2022 06:59
-
-
Save riccardomerolla/31e959db3e01e8326b41e4094f75e074 to your computer and use it in GitHub Desktop.
Fibonacci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(num: Int): BigInt = | |
@scala.annotation.tailrec | |
def fibFcn(n: Int, acc1: BigInt, acc2: BigInt): BigInt = n match | |
case 0 => acc1 | |
case 1 => acc2 | |
case _ => fibFcn(n - 1, acc2, acc1 + acc2) | |
fibFcn(num, 0, 1) | |
fibonacci(90) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment