factorial
Calculates the factorial of a number.
- Use recursion.
- If
nis less than or equal to1, return1. - Otherwise, return the product of
nand the factorial ofn - 1. - Throw a
TypeErrorifnis a negative number.
Calculates the factorial of a number.
n is less than or equal to 1, return 1.n and the factorial of n - 1.TypeError if n is a negative number.