We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 32fa90f commit e9d131aCopy full SHA for e9d131a
solutions/scala/Fibonacci.scala
@@ -0,0 +1,7 @@
1
+object Fibonacci {
2
+ // accept a pos, starting with 1
3
+ def apply(pos: Int) = {
4
+ if (pos < 0) throw new IllegalArgumentException
5
+ (1 until pos).foldLeft((0, 1))((t, _) => (t._2, t._1 + t._2))._1
6
+ }
7
+}
0 commit comments