`python
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)
`
Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.

### Instruction:
Write a Python function to calculate the factorial of a number.

### Input:


### Response:
`python
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)
`<|im_end|>