Implement a Python function that calculates the factorial of a given number.
def factorial(n):
if n == 0:
return 1
return n * factorial(n - 1)
print(factorial(5)) # 120
note
To compile and run the program, you can use the following commands:
python3 foo.py