Skip to content

Instantly share code, notes, and snippets.

@maniish-jaiin
Created April 8, 2021 20:15
Show Gist options
  • Select an option

  • Save maniish-jaiin/e0e0ab3d97765e22958e4dee33b90768 to your computer and use it in GitHub Desktop.

Select an option

Save maniish-jaiin/e0e0ab3d97765e22958e4dee33b90768 to your computer and use it in GitHub Desktop.
fun fibonacciFold(n: Int) =
(2 until n).fold(1 to 1) { (prev, curr), _ ->
curr to (prev + curr)
}.second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment