Calculate Factorial
MATH
RECURSION

Problem

Given a non-negative integer n, return the factorial of n.

The factorial of a number is the product of all positive integers up to that number. The factorial of 0 is defined as 1.

Examples

factorial(0) // 1 factorial(1) // 1 factorial(5) // 120 /* The factorial of 5 is 5 * 4 * 3 * 2 * 1 = 120. */
Loading...