Corrected solution to factorial function

This commit is contained in:
ThirtyThreeB 2018-01-03 12:10:49 -05:00 committed by GitHub
parent 35ed3d7b44
commit 83a2b6aead
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,12 +19,10 @@ function power(a, b) {
} }
function factorial(n) { function factorial(n) {
if (n == 0) return 0; if (n===0){
let product = 1; return 1;
for (let i = n; i > 0; i--) { }
product *= i; return n * factorial (n-1);
}
return product;
} }
module.exports = { module.exports = {