Brian Yang
Brian Yang
algorithm designer
Mar 25, 2020 1 min read

Factorial

Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example factorial of 6 is 65432*1 which is 720.

Solution

const factorial = number => {
  return number < 2 ? 1 : number * factorial(number - 1)
}
comments powered by Disqus