Skip to content

Commit 7e81bb8

Browse files
authored
Update First Factorial
1 parent b8f2465 commit 7e81bb8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

First Factorial

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
* *
2323
***************************************************************************************/
2424

25-
function FirstFactorial(num) {
26-
27-
var tot = 1;
28-
for (var i = 2; i <= num; i++) {
29-
tot *= i;
25+
function FirstFactorial(num) {
26+
let factorial = 1;
27+
for (let i = 1; i <= num; i++) {
28+
factorial *= i;
3029
}
31-
32-
return tot;
33-
30+
return factorial;
3431
}
32+
33+
// Test cases
34+
console.log(FirstFactorial(4)); // Expected output: 24
35+
console.log(FirstFactorial(5)); // Expected output: 120
36+
console.log(FirstFactorial(1)); // Expected output: 1

0 commit comments

Comments
 (0)