Skip to content

Instantly share code, notes, and snippets.

@we4tech
Created September 5, 2017 03:32
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 we4tech/7d73eee502ed5a0a8f54dee65dfe39ea to your computer and use it in GitHub Desktop.
Save we4tech/7d73eee502ed5a0a8f54dee65dfe39ea to your computer and use it in GitHub Desktop.
Fibonacci series upto n
fun findFibSeries(n: Int) {
val series = mutableListOf(0, 1)
(0..n).map { n ->
series.add(series.takeLast(2)
.reduce {sum, it -> sum + it})
}
series.forEach { println(it) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment