Factorial

Factorial#

Write a function factorial(n) that returns n! with the help of a for loop and the range() function. Recall that the factorial of an integer is calculated by multiplying each positive integer up to that number. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120.

You can assume n is a non-negative integer. (Remember, 0! is 1)

The input and printing is already handled for you in the background. You only need to implement the function and return the result of computing the factorial of the number provided as an input parameter.

Sample Input 1:

4

Sample Output 1:

24

Sample Input 2:

5

Sample Output 2:

120