Contact Learn C
Copy Program Share Program

Program 180:Sum of Series 1/1!+2/2!+3/3!+4/4!....+1/N!

Program 180:
 
#include<stdio.h>
int factorial(int);
main()
{ 
int i,n;
float sum=0;
printf("Enter value of n\n");
scanf("%d",&n);


for(i=1;i<=n;i++)
{
 sum+=(float)i/factorial(i);
}
printf("The value of\n");
for(i=1;i<=n;i++)
{
 if(i<n)
 {
  printf("%d/%d!+ ",i,i);
 }
 else
 {
  printf("%d/%d!= ",i,i);
 }
 
}
printf("%f\n",sum);

}

int factorial(int num)
{
 int i,fact=1;
 for(i=1;i<=num;i++)
 {
  fact=fact*i;
 }
 
 return(fact);
}

Explanation:

//Coming Soon...

Output:





 

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide