Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.