Problem 2: Factorial (100pts)

Write a function that takes a positive integer \( n \) and returns its factorial.

Factorial of a positive integer \( n \) is defined as

\[ n! = \prod_{i=1}^n i = 1 \times 2 \times 3 \times \dots \times n. \]

def factorial(n):
    """Return the factorial of a positive integer n.

    >>> factorial(3)
    6
    >>> factorial(5)
    120
    """
    pass  # YOUR CODE HERE

pass的作用:正如冯老师在课上所说,pass是一条“空指令”,表示什么都不做。

通常,当我们定义一个函数,但没有想好函数怎么实现的时候,我们就会填入一个pass来保持程序结构的正确性。大家在完成lab和后续作业的时候,应该先把这一行pass语句删除,然后再编写自己的代码,请不要在提交的代码中包含pass

Test your implementation with python ok -q factorial.