908. Factorial of a given number

You are given an integer n. Return the value of n! or n factorial.

Factorial of a number is the product of all positive integers less than or equal to that number.

Example 1:

Input: n = 2

Output: 2

Explanation: 2! = 1 * 2 = 2.

Example 2:

Input: n = 0

Output: 1

Explanation: 0! is defined as 1.

Now Your Turn!

Pick the correct output for the given input

Input: 3

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 0 <= n <= 10
0
class Solution {
public:
int factorial(int n) {
 
}
};
 
Test Case

Input:

Nums