Skip to content

Instantly share code, notes, and snippets.

@alexandreaquiles
Last active April 16, 2018 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandreaquiles/4754635 to your computer and use it in GitHub Desktop.
Save alexandreaquiles/4754635 to your computer and use it in GitHub Desktop.
Lazy Fibonacci Sequence in Scala, using Streams.
def fibonacciSequence : Stream[Long] = {
def fibonacciFrom(a: Long, b: Long) : Stream[Long] = a #:: fibonacciFrom(b, a+b)
fibonacciFrom(0, 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment