Skip to content

Commit d27fc26

Browse files
committed
Factorial
1 parent a0cf580 commit d27fc26

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Programs/Basic/factorial.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
3+
/*
4+
5+
WAP in Js Factorial of a Number
6+
*/
7+
function factorial(n) {
8+
9+
if (n==0||n==1) {
10+
11+
return 1;
12+
13+
} else{
14+
15+
return n*factorial(n-1)
16+
}
17+
18+
}
19+
20+
console.log("Factorial Of a Number = ",factorial(5))
21+
22+
23+

0 commit comments

Comments
 (0)