TASK-
Write a C-program to add entered terms of the following series: 1/(1!) + 2/(2!) + 3/(3!) + 4/(4!) + …
CRACKING:
- Each number is divided by its factorail
- Algorithm to find factorail
- To get more clear concept about factorail finding Click here: 👉👉 Factorail
CODE:
#include<stdio.h>
int main(){
int r,fact=1;
float sum=0;
printf("\tNumber of terms? : ");
scanf("%d",&r); //asking for number of terms
printf("\n");
for (int i=1;i<=r;i++)
{
//factorail calculation is here
for (int j=1;j<=i;j++)
{
fact=fact*j;
}
printf("\t%d/%d!",i,i);
if (i!=r)
printf(" + ");
sum=sum+(float(i)/fact);
fact=1;
}
printf("\n\tSum of %d terms is %0.2f",r,sum);
getchar();
return 0;
}
Expected Output: