Factorial (Recursive)
Medium
recursion
math
Description
Calculate the factorial of a non-negative integer `n` using recursion. The factorial of a number is the product of all integers from 1 to that number.
Examples
Example:
Input: n = 5
Output: 120
Explanation: 5! = 5 * 4 * 3 * 2 * 1 = 120.
Constraints
- Input n is a non-negative integer.
- Must use recursion.
Loading...
Test Case 1
Input: 5
Output: 120
Test Case 2
Input: 0
Output: 1
Test Case 3
Input: 1
Output: 1
Test Case 4
Input: 4
Output: 24
