Created
October 16, 2011 14:16
-
-
Save btd/1290914 to your computer and use it in GitHub Desktop.
One line fib numbers without recursion and scala.math
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val fib = (n:Int) => (0 until n).foldLeft(0, 1) { (x, i) => (x._2, x._1 + x._2) }._1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment