Skip to content

Commit 5b0b04e

Browse files
Ensure factorial is calculated for 0 (#102)
Ensure a unique solution for res0. Without the check, both answers 0 and 1 pass the test. Co-authored-by: James Santucci <[email protected]>
1 parent 8bdde5e commit 5b0b04e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/scala/scalatutorial/sections/TailRecursion.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ object TailRecursion extends ScalaTutorialSection {
145145
iter(n, res1)
146146
}
147147

148+
factorial(0) shouldBe 1
148149
factorial(3) shouldBe 6
149150
factorial(4) shouldBe 24
150151
}

0 commit comments

Comments
 (0)