
									 Problem
								
								
									 Solution
								
								
									 Submissions
								
								
							Recursive Function to Compute Factorial
								Certification: Intermediate Level
								Accuracy: 71.43%
								Submissions: 7
								Points: 10
							
							Write a Python function that calculates the factorial of a given number using recursion. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n.
Example 1
- Input: 5
- Output: 120
- Explanation: 
    - Step 1: Take the input number 5.
- Step 2: Calculate the factorial: 5 × 4 × 3 × 2 × 1 = 120.
- Step 3: Return 120 as the result.
 
Example 2
- Input: 0
- Output: 1
- Explanation: 
    - Step 1: Take the input number 0.
- Step 2: The factorial of 0 is defined as 1.
- Step 3: Return 1 as the result.
 
Constraints
- 0 ≤ n ≤ 998 (Python recursion limit may be reached for larger values)
- Return the factorial of the input number
- Time Complexity: O(n), where n is the input number
- Space Complexity: O(n) due to the recursion stack
Editorial
									
												
My Submissions
										All Solutions
									| Lang | Status | Date | Code | 
|---|---|---|---|
| You do not have any submissions for this problem. | |||
| User | Lang | Status | Date | Code | 
|---|---|---|---|---|
| No submissions found. | ||||
Solution Hints
- Base case: if n is 0 or 1, return 1
- Recursive case: return n * factorial(n-1)
- Consider using memoization for optimization
- Handle edge case for negative numbers
