Skip to content

Commit bbda638

Browse files
Update Factorial.js
1 parent 7bdb8d5 commit bbda638

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

JavaScript Interview Programs/Factorial.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
// ******************************************************** Factorial **************************************************
33

44
// 1. Factorial of a number:
5-
65
// Using For Loop:
7-
function factorialLoop(n) {
6+
function factorial(n) {
87
let fact = 1;
98
for (let i = 1; i <= n; i++) {
10-
fact *= i;
9+
fact *= i; // fact = fact * i;
1110
}
1211
return fact;
1312
}
14-
console.log("Factorial (Loop):", factorialLoop(5));
13+
console.log("Factorial (using For Loop):", factorial(5));

0 commit comments

Comments
 (0)