#include<math.h>
#include<stdio.h>
#include<conio.h>
int main()
{
long n,s=-1,i,j;
printf("\nEnter the max limit:");
scanf("%ld", &n);
printf("\nThe sum of the series %ld+",s);
for(i=1;i<=n-1;i++)
{
if(i%2!=0)
{
s=s+(pow(2,(2*i+1))+1)/3;
j=(pow(2,(2*i+1))+1)/3;
printf("%ld",j);
}
else
{
s=s-(pow(2,(2*i+1))+1)/3;
j=(pow(2,(2*i+1))+1)/3;
printf("%ld+",(-1*j));
}
}
printf("\nThe sum of the series is : ");
printf("%ld",s);
getche();
return 0;
}
0 comments:
Post a Comment