1function factorial(n) {
2 if (n < 0) return;
3 if (n < 2) return 1;
4 return n * factorial(n - 1);
5}
1// Simple arrow function solution
2var factorial = n => (n <= 0) ? 1: n * factorial(n - 1);
1 function factorial(n) {
2 if (n > 1) {
3 return n * factorial(n - 1);
4 }
5 return 1;
6 }