function factorial(n) {
  // Base case: if n is 0, return 1
  if (n === 0) {
    return 1;
  }
  // Recursive case: n * factorial of (n - 1)
  return n * factorial(n - 1);
}

// Test cases
console.log(factorial(5)); // => 120
console.log(factorial(3)); // => 6
console.log(factorial(0)); // => 1
