-
-
Save maniish-jaiin/d0d4053ccdac8f366dc83c77a65b3cd5 to your computer and use it in GitHub Desktop.
This file contains 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
fun fibonacci(n: Int, a: Int = 0, b: Int = 1): Int = | |
when (n) { | |
0 -> a | |
1 -> b | |
else -> fibonacci(n - 1, b, a + b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment