标签:
程序2-4
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int n, count = 0; 6 scanf("%d",&n); 7 while(n>1) 8 { 9 if(n % 2 ==1) n = 3*n +1; 10 else n/=2; 11 count++; 12 } 13 printf("%d\n",count); 14 return 0; 15 }
程序2-5
1 #include<stdio.h> 2 #include<math.h> 3 int main() 4 { 5 int i, j, n, S = 0; 6 scanf("%d",&n); 7 for(i = 1;i<=n;i++) 8 { 9 int factorial = 1; 10 for(j = 1;j <=i;j++) 11 { 12 factorial *= j; 13 } 14 S +=factorial; 15 } 16 printf("%d\n",S % 1000000); 17 return 0; 18 }
标签:
原文地址:http://www.cnblogs.com/LzKlyhPorter/p/4189460.html