正整数n的阶乘由n!
表示 并定义如下:
n! = 1 x 2 x ..... x n
例如:
0! = 1
1! = 1
2! = 1 x 2 = 2
3! = 1 x 2 x 3 = 6
示例代码:
#include <stdio.h>
int main(){
int counter= 10;
unsigned long int result = 1;
char ch;
for (int i = 1; i <= counter; i++) {
result = result * i;
}
printf("Required factorial is: %lu/n", result);
return(0);
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266583.html