Factorial Of A Given Number

Think before you code.

Compute n! for a small n with a single accumulating loop.

easy

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.

Example 3

Input : 3
Output : 6

Constraints

  • 0 <= n <= 10