JavaScript:实现计算排列和组合的数量算法
/**
* @brief Calculates the factorial of the given number.
* @param num: integer
* @details Factorial of n = n * (n - 1) * (n - 2) * ... * 1
* @returns integer: Factorial of the number.
NaN: if negative number is provided.
*/
const factorial = (n) => {
if (