Construct an algorithm in Python that calculates the factorial of a number
n = 5
def factorial(number):
    factorial = 1
    for i in range(1, number + 1):
        factorial = factorial * i
    return factorial

n = 5
result = factorial(n)
print(result) # 120