Write a recursive function factorial(n) that returns n
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Write a recursive function factorial(n) that returns n! (n * factorial(n-1), base case: factorial(0) = 1). Print factorial(5) and factorial(0).
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.