Problem
The factorial of n, written n!, is 1 × 2 × … × n. By definition 0! = 1.
Implement factorial(n).
Input
n: A non-negative integer.
Output
Return n!.
Constraints
0 ≤ n ≤ 20, so the result fits a signed 64-bit integer.
Examples
Example 1
Input:
n = 5
Expected output:
expected = 120
Input:
long long n = 5;
Expected output:
long long expected = 120;
Input:
long n = 5;
Expected output:
long expected = 120;
Explanation
1 × 2 × 3 × 4 × 5 = 120.
Example 2
Input:
n = 0
Expected output:
expected = 1
Input:
long long n = 0;
Expected output:
long long expected = 1;
Input:
long n = 0;
Expected output:
long expected = 1;
Explanation
0! is defined as 1.