#CCBCHBA0000037. Giai thừa có kiểm miền (Factorial Within Range)
Giai thừa có kiểm miền (Factorial Within Range)
Factorial Within Range
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Calculate n factorial with a for loop; define 0!=1. The range 0..20 fits signed 64-bit.
Input
One integer n, 0<=n<=20.
Output
n! as a signed 64-bit integer.
Subtasks
- Subtask 1 (20%): 0<=n<=5.
- Subtask 2 (30%): 0<=n<=12.
- Subtask 3 (50%): 0<=n<=20.
Examples
Example 1
Input
0
Output
1
Explanation
The empty product equals 1.
Example 2
Input
5
Output
120
Explanation
Multiply 1 through 5.