1130: 零起点学算法37——求阶乘
1130: 零起点学算法37——求阶乘
Time Limit: 1 Sec Memory Limit: 64 MB 64bit IO Format: %lldSubmitted: 2109 Accepted: 1328
[Submit][Status][Web Board]
Description
输入一个正整数n,计算它的阶乘
Input
输入一个正整数n(n<=10)(多组数据)
Output
输出n的阶乘(每组数据一行)
Sample Input
3
Sample Output
6
Source
1 #include<stdio.h> 2 int main(){ 3 int n; 4 while(scanf("%d",&n)!=EOF){ 5 long long num=1; 6 for(int i=n;i>0;i--){ 7 num*=i; 8 } 9 printf("%lld\n",num); 10 } 11 return 0; 12 }