In JavaScript Create a Function that Takes a Number to Return a Factorial
Posted on June 15, 2015 in Algorithms, JavaScript by Matt Jennings
function factorialInput(num) { var factorial = 1; for(var i = num; i > 0; i--) { factorial *= i; } return factorial; } /* Output below is: 1 * 2 * 3 * 4 * 5 = 120 */ console.log(factorialInput(5));