2.8

#include<stdio.h>

double fact(int n);

int main(void)

{

         int i,n;

         double e;

 

         printf("Enter n:");

         scanf("%d",&n);

         e=0;

 

         for(i=0;i<=n;i++){

                   e=e+fact(i);

         }

                   printf("%.0f\n",e);

        

         return 0;

}

double fact(int n)

{

int i;

double result;

result=1;

for(i=1;i<=n;i++){

         result=result*i;

 

 

        

}

 

 

return result;

}

posted @ 2013-10-19 23:30  zhaoyang16  阅读(130)  评论(0编辑  收藏  举报