Skip to content

Instantly share code, notes, and snippets.

@jesty
Last active May 15, 2018 08:39
Show Gist options
  • Save jesty/c557a481a1a566239766ee2880a51f24 to your computer and use it in GitHub Desktop.
Save jesty/c557a481a1a566239766ee2880a51f24 to your computer and use it in GitHub Desktop.
Fibonacci in Scala
def seriesUntilPosition(n: Int) = (0 until n)
.map(x => (0,0))
.foldLeft((0,1))((acc, b) => (acc._2, acc._1 + acc._2))._2
def seriesUntil(n: Int) = (0 to n).map(fibo(_)) (
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment