factorial
Calculates the factorial of a number.
- Use recursion.
- If
n
is less than or equal to1
, return1
. - Otherwise, return the product of
n
and the factorial ofn - 1
. - Throw a
TypeError
ifn
is 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.