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 4b44a61 commit e3446a1Copy full SHA for e3446a1
lesson_07/conditionals/src/lesson7.ts
@@ -27,7 +27,22 @@ export function compareStrings(a: string, b: string): number {
27
* @return The factorial of n.
28
*/
29
export function computeFactorial(n: number): number {
30
- return 0;
+ // worked with Davis to complete this coding problem
31
+ // edge cases
32
+ if (n === 0) {
33
+ return 1;
34
+ }
35
+ if (n === 1) {
36
37
38
+ if (n < 0) {
39
+ return 0;
40
41
+ let result = 1;
42
+ for (let i = 2; i <= n; i++) {
43
+ result *= i;
44
45
+ return result;
46
}
47
48
/**
0 commit comments