Problem 1
Factorial Recursion Challenge
Given a non-negative integer n, return its factorial. The factorial of n is the product of all positive integers less than or equal to n. If n is negative, return null.
Function Signature
factorial(n)
Parameters
n— an integer
Output
Return a number representing the factorial of n, or null if n is negative.
Constraints
- The function must use recursion.
- The function should accept exactly one argument.
Examples
factorial(0) → 1
factorial(1) → 1
factorial(4) → 24
factorial(5) → 120
factorial(-5) → null