# Factorial of a Number

## Problem Statement

In this challenge, you must find the factorial of a given number.

If `n` is the given number, then the factorial of `n` is given by the following formula.

``n! = 1 * 2 * 3 * ... * n``

## Input

The first line of input consists of an integer `n`, where `n>=0`.

## Output

Print the factorial of given number.

## As is

The boilerplate code is already there to read the input from user, in the `main()` function, and to print the value returned by the `factorial()` function. Do not edit this code.

## To do ✍

`factorial()` has one parameter: `n`. Complete the function that computes the factorial of given number, and return the result.

## Example 1

Test input

``5``

Test output

``120``

Explanation

``````5! = 1 * 2 * 3 * 4 *5
= 120``````

## Example 2

Test input

``3``

Test output

``6``

## Python Program

``````# Complete the following function
def factorial(n):

# Boilerplate code - Do not edit the following
def main():
n = int(input())
print(factorial(n))

if __name__ == "__main__":
main()``````

Input and Outputs 1

``1``
``1``

Input and Outputs 2

``5``
``120``

Input and Outputs 3

``7``
``5040``

Input and Outputs 4

``10``
``3628800``

Input and Outputs 5

``0``
``1``
``````# Complete the following function
def factorial(n):
if n == 0:
return 1
else:
result = 1
for i in range(1, n+1):
result *= i
return result

# Boilerplate code - Do not edit the following
def main():
n = int(input())
print(factorial(n))

if __name__ == "__main__":
main()``````