aboutsummaryrefslogtreecommitdiff
path: root/entries/jyoo980
diff options
context:
space:
mode:
Diffstat (limited to 'entries/jyoo980')
-rw-r--r--entries/jyoo980/scala/Fib.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/entries/jyoo980/scala/Fib.scala b/entries/jyoo980/scala/Fib.scala
new file mode 100644
index 0000000..05bdd1e
--- /dev/null
+++ b/entries/jyoo980/scala/Fib.scala
@@ -0,0 +1,6 @@
+def fib(n: Int) =
+ (0 until n).foldLeft((0, 1)) {
+ case ((prev, curr), _) => (curr, prev + curr)
+ } match {
+ case (n, _) => n
+ }