Skip to content

Instantly share code, notes, and snippets.

@maniish-jaiin
Created April 8, 2021 20:14
Show Gist options
  • Save maniish-jaiin/d0d4053ccdac8f366dc83c77a65b3cd5 to your computer and use it in GitHub Desktop.
Save maniish-jaiin/d0d4053ccdac8f366dc83c77a65b3cd5 to your computer and use it in GitHub Desktop.
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