Skip to content

Commit 4cda468

Browse files
authored
Create Factorial.js
1 parent acbf60c commit 4cda468

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

factorial_8/Factorial.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const iterativeFact = num => {
2+
let res = 1
3+
for(let x = 1; x <= num; x++)
4+
{
5+
res *= x
6+
}
7+
return res
8+
}
9+
10+
const recursiveFact = num => {
11+
if(num === 1 || num === 0)
12+
{
13+
return num
14+
}
15+
else
16+
{
17+
return num * recursiveFact(num - 1)
18+
}
19+
}

0 commit comments

Comments
 (0)