Steps:

  • Create program using recursion
  • Until the value is not equal to zero, the recursive function will call itself
function factorial(n) {
    if (n === 0) {
        return 1;
    }
    return n * factorial(n - 1);
}

factorial(5)

References: