Skip to content

Instantly share code, notes, and snippets.

@dtrailin
Created August 25, 2016 21:59
Show Gist options
  • Select an option

  • Save dtrailin/5ebba8ff2cfcfd34aaa6b26f795dedd5 to your computer and use it in GitHub Desktop.

Select an option

Save dtrailin/5ebba8ff2cfcfd34aaa6b26f795dedd5 to your computer and use it in GitHub Desktop.
tailrec fun fib(count: Long, seq: List<Int> = listOf(1,1)): List<Int> =
if (seq.size >= count) seq else fib(count, seq + (seq.last() + seq[seq.lastIndex - 1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment