Skip to content

Instantly share code, notes, and snippets.

@maniish-jaiin
Created April 8, 2021 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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