Challenge
Using the C# language, have the function
FirstFactorial(num) take the
num parameter being passed and return the factorial of it (
e.g. if
num = 4, return
(4 * 3 * 2 * 1)). For the test cases, the range will be between 1 and 18 and the input will always be an integer.
Sample Test Cases
Input:4
Output:24
Input:8
Output:40320
First Factorial算法是求一个自然数[1-18]的阶乘。
public static int FirstFactorial(int num)
{
int sum = 1;
while (num > 0)
{
sum *= num;
num--;
}
return sum;
}