Answers for "factorial javascript function"

16

javascript factorial

function factorial(n) {
  if (n < 0) return;
  if (n < 2) return 1;
  return n * factorial(n - 1);
}
Posted by: Guest on May-24-2020
1

how to make a factorial function in javascript

function factorialize(num) {
  var result = num;
  if (num === 0 || num === 1) 
    return 1; 
  while (num > 1) { 
    num--;
    result *= num;
  }
  return result;
}
Posted by: Guest on March-22-2020
0

factorial function javascript

function factorial(n) {
        if (n > 1) {
            return n * factorial(n - 1);
        }
        return 1;
    }
Posted by: Guest on December-30-2020
0

factorial in javascript using for loop

function factorialize(num) {
  if (num < 0) 
        return -1;
  else if (num == 0) 
      return 1;
  else {
      return (num * factorialize(num - 1));
  }
}
factorialize(5);
Posted by: Guest on December-13-2020
0

factorial javascript function

function factorialize(num) {
  if(num < 2) return 1;
  return num *= factorialize(num - 1);
}
Posted by: Guest on July-24-2020

Code answers related to "factorial javascript function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language