Skip to content

Commit cad01bd

Browse files
author
Thea
committed
factorial
1 parent d8701a6 commit cad01bd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

factorialize.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,16 @@ function factorialize(num) {
55
}
66

77
return factorial;
8+
}
9+
10+
11+
12+
//Another way to solve (recursion)
13+
14+
function factorial(num){
15+
if(num === 0){
16+
return 1;
17+
}
18+
19+
return num * factorial(num -1);
820
}

0 commit comments

Comments
 (0)