Skip to content

Instantly share code, notes, and snippets.

@leedm777
Created May 7, 2012 19:34
Show Gist options
  • Save leedm777/2629874 to your computer and use it in GitHub Desktop.
Save leedm777/2629874 to your computer and use it in GitHub Desktop.
fibonacci sequence, in scala
val fib: Stream[BigInt] = {
def nextFib(a: BigInt, b: BigInt): Stream[BigInt] = {
Stream.cons(a + b, nextFib(b, a + b))
}
Stream.cons(0, Stream.cons(1, nextFib(0, 1)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment