Solution: Factorialize a number - freeCodeCamp (Basic Algorithm Scripting)

 Factorialize a Number


Return the factorial of the provided integer.

If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

Factorials are often represented with the shorthand notation n!

For example: 5! = 1 * 2 * 3 * 4 * 5 = 120

Only integers greater than or equal to zero will be supplied to the function. 


SOLUTION:


function factorialize(num) {
  if(num === 0) {
    return 1;
  }
  return num * factorialize(num-1);
}

factorialize(5);
console.log(factorialize(5))

Factorialize a number - the dawnsoft

Click here to go to the original link of the question.

Post a Comment

Previous Post Next Post