Skip to content

Instantly share code, notes, and snippets.

@maniish-jaiin
Created Apr 8, 2021
Embed
What would you like to do?
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