Skip to content

Commit 1d208ed

Browse files
author
munnaSorder
committed
add recursive
1 parent 2d6d726 commit 1d208ed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

recursiveFactorial.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function factorial (n){
2+
if(n == 0){
3+
return 1;
4+
}
5+
else{
6+
return n * factorial(n-1);
7+
}
8+
}
9+
const result = factorial(10);
10+
console.log(result);
11+
//output 3628800

0 commit comments

Comments
 (0)