When m is a natural number, it means the product of all positive integers not exceeding m and having the same parity with m.
Example:
3! ! = 1*3=3。
5! ! = 1*3*5= 15。
6! ! =2*4*6=48。
Calculation skills of factorial in computer programs;
To calculate the factorial of 5, we first define a variable to store the final answer, and the initial value is set to 1, such as intsum =1; You can define a variable as 5 in the for loop, such as int I = 5;; Then multiply the sum by i.
So the initial value of sum must not be 0, otherwise it is meaningless. Then let me subtract 1 every time, which is I-; ; Multiply sum by I until the value of I equals 1, end the for loop, and then output the value of sum.