We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7bdb8d5 commit bbda638Copy full SHA for bbda638
1 file changed
JavaScript Interview Programs/Factorial.js
@@ -2,13 +2,12 @@
2
// ******************************************************** Factorial **************************************************
3
4
// 1. Factorial of a number:
5
-
6
// Using For Loop:
7
-function factorialLoop(n) {
+function factorial(n) {
8
let fact = 1;
9
for (let i = 1; i <= n; i++) {
10
- fact *= i;
+ fact *= i; // fact = fact * i;
11
}
12
return fact;
13
14
-console.log("Factorial (Loop):", factorialLoop(5));
+console.log("Factorial (using For Loop):", factorial(5));
0 commit comments