aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBraxton Hall2022-10-23 21:40:30 +0000
committerGitHub2022-10-23 21:40:30 +0000
commita0fab0d8ac452063375d4bba76466803c28258f0 (patch)
tree6bb0e219d757c4b01f374411758d4720766da52f
parent3de00aa8511713c50564fa183671486530fdc0ae (diff)
parent9d6f7b9b5123c6e6d8d5a13ee3f4b5f63a0cf663 (diff)
Merge pull request #2 from jyoo980/main
Adding fib in Scala
-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..f9107b0
--- /dev/null
+++ b/entries/jyoo980/scala/Fib.scala
@@ -0,0 +1,6 @@
+def fib(n: Int): Int =
+ (0 until n).foldLeft((0, 1)) {
+ case ((prev, curr), _) => (curr, prev + curr)
+ } match {
+ case (n, _) => n
+ }