Catherine_zhilin

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

求1+2!+3!+.......+n!

代码;

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 5 void main(){
 6     
 7     int s;//和为s 
 8     int n;
 9     scanf("%d",&n);
10     s=0;//给和赋初值为0 
11     //二重循环循环遍历i,j 
12     int i;
13     int j;
14         int t;//计算每个数阶乘的值 
15     for(i=1;i<=n;i++){
16         t=1;
17         for(j=1;j<=i;j++)
18         {
19             t=t*j;
20         } 
21         s=s+t;
22         }
23     
24         printf("和为%d",s);
25 }
26                                                                                                                                                                        
1+2!+3!+......+n!

 

posted on 2018-11-12 13:27  kkkshiki  阅读(890)  评论(0编辑  收藏  举报