Skip to content

Instantly share code, notes, and snippets.

@lotharschulz
Created October 23, 2022 18:52
Show Gist options
  • Save lotharschulz/2c97269489aa7e4f050591eaae8a9577 to your computer and use it in GitHub Desktop.
Save lotharschulz/2c97269489aa7e4f050591eaae8a9577 to your computer and use it in GitHub Desktop.
val fibonacci = sequence {
yield(1)
var cur = 1
var next = 1
while (true) {
yield(next)
val tmp = cur + next
cur = next
next = tmp
}
}
println(fibonacci.take(15).joinToString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment