Implement a Python program that takes a positive integer as its input and returns its factorial.
3
def factorial(n):
    if n < 0:
        raise ValueError("Input must be a positive integer")
    if n == 0:
        return 1
    res = 1
    for i in range(2,n+1):
        res *= i
    return res