Javascript Number Integer factorial
function factorial(n){ if(n < 0 ) return 'does not exist'; if(n === 0 || n === 1) return 1; var x = 1;/*w w w.j a v a 2 s . c o m*/ for(var i = 1; i <= n; i++){ x *= i } return x; } console.log(factorial(-6)); console.log(factorial(0)); console.log(factorial(1)); console.log(factorial(2)); console.log(factorial(3)); console.log(factorial(5)); console.log(factorial(9));