Pages

Tuesday, 16 June 2015

Series 2

Number Series 2:
1!+2!+3!+...+n!

Coding:
#include<stdio.h>
int main()
{
int i,n,j,p,sum=0;
printf("Please enter the number of terms:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1,p=1;j<=i;j++)
p=p*j;
sum=sum+p;
}
printf("Result is:%d",sum);
return 0;
}

Output:
Please enter the number of terms:5
Result is:153
>