Write an algorithm in Python 3 that calculates the factorial of a number.

Input: Not applicable

Output: def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)

Prompt: Below is an instruction that describes a task. Write a response that appropriately completes the request.

### Instruction:
Write an algorithm in Python 3 that calculates the factorial of a number.

### Input:
Not applicable

### Output:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)