// Program by Akash Tripathi (@proakash256)
#include <stdio.h>
unsigned long long factorial(int n)
{
unsigned long long f = 1;;
for(int i = n; i >= 2; i = i - 1)
f = f * i;
return f;
}
int main()
{
int n;
float s = 0;
printf("Enter the number of terms upto which you want to
print the series : ");
scanf("%d" , &n);
for(int i = 1; i <= n; i = i + 1)
{
unsigned long long f = factorial(i);
s = s + (i / (float)f);
}
printf("\nThe Sum of the series upto %d terms is %0.2f" , n , s);
return 0;
}
Comments
Post a Comment