Write a self-terminating recursive function for a basic programming problem.
For this exercise, implement factorial(n), which returns the factorial of a non-negative integer. Define a base case that stops recursion and a recursive case that reduces the input toward that base case.
Function: def factorial(n):
The function returns an integer, and valid inputs satisfy 0 <= n <= 20.
def factorial(n):