创建一个计算阶乘的Python函数。
n = 5
下面是一个计算n的阶乘的Python函数:

```python
def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)

n = 5
result = factorial(n)
print(result)
```

输出: 

```
120
```