#include<stdio.h>
#include<conio.h>
double fact(int n);
void main()
{
int n,i;
double sum=0.0;
clrscr();
printf("Up To Which Term ?");
scanf("%d",&n);
for(i=1;i<=n;++i)
sum+=fact(i);
printf("Sum Of The Factorials Of The Numbers Up To %d Is %g",n,sum);
getch();
}
double fact(int n)
{
int i;
double f=1.0;
for(i=2;i<=n;++i)
f*=i;
return f;
}
No comments:
Post a Comment