You are viewing a single comment's thread. Return to all comments →
Looks a bit hacky but simple. Scala.
def fibonacci(x:Int):Int = { if(x <= 1) x else { (1 to x-1).foldLeft((0, 1)) { case ((a,b), i) => (b, a+b) }._1 } }
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci Numbers
You are viewing a single comment's thread. Return to all comments →
Looks a bit hacky but simple. Scala.