Created
September 5, 2017 03:32
-
-
Save we4tech/7d73eee502ed5a0a8f54dee65dfe39ea to your computer and use it in GitHub Desktop.
Fibonacci series upto n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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