Negative factorial in JavaScript
Changing your function to something like this would work. I don't think you need to model your function after the mathematical equation.

function factorial(num) {
  if (num &lt; 0) {
    return num * factorial(num + 1);
  } else if (num == 0) {
    return 1;
  } else {
    return num * factorial(num - 1);
  }
}


Another solution that uses tail call optimization could be

function factorial(num) {
  function recur(n, acc) {
    if (n &lt; 0) {
      return recur(n + 1, n * acc);
    } else if (n == 0) {
      return acc;
    } else {
      return recur(n - 1, n * acc);
    }
  }
  return recur(num, 1);
}