Skip to content

Commit c1033c2

Browse files
author
“Tezz03”
committed
fix: lesson_07
1 parent 7ee51a4 commit c1033c2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lesson_07/conditionals/src/lesson7.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,15 @@ export function compareStrings(a: string, b: string): number {
3232
* 5! = 5*4! factorial equation
3333
*/
3434
export function computeFactorial(n: number): number {
35-
if (n === 0 || n === 1) {
35+
if (n === 0) {
3636
return 1;
3737
}
38+
else if (n === 1) {
39+
return 1;
40+
}
41+
else if (n < 0) {
42+
return 0;
43+
}
3844
else {
3945
return n * computeFactorial(n-1);
4046
}

0 commit comments

Comments
 (0)