diff --git a/KOTLIN/fibonacci.kt b/KOTLIN/fibonacci.kt new file mode 100644 index 00000000..66a260fa --- /dev/null +++ b/KOTLIN/fibonacci.kt @@ -0,0 +1,11 @@ +fun main() { + println(fibonacci().take(10).toList()) +} + +fun fibonacci() = sequence { + var terms = Pair(0, 1) + while (true) { + yield(terms.first) + terms = Pair(terms.second, terms.first + terms.second) + } +} \ No newline at end of file