Featured
- Get link
- X
- Other Apps
C++ program to sum the divergent series
// sum the divergent series (1)+(1+2)+(1+2+3)+(1+2+3+4+....+n)
#include<iostream.h>
void main()
{
long int n,i,j,sum=0;
cout<<"\nEnter The Limit\n";
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"(";
for(j=1;j<=i;j++)
{
cout<<j<<"+";
sum=sum+j;
}
cout<<"\b" ;
cout<<")+";
}
cout<<"\b";
cout<<"\nSUM OF SERIES IS :"<<sum;
}
OUTPUT:
#include<iostream.h>
void main()
{
long int n,i,j,sum=0;
cout<<"\nEnter The Limit\n";
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"(";
for(j=1;j<=i;j++)
{
cout<<j<<"+";
sum=sum+j;
}
cout<<"\b" ;
cout<<")+";
}
cout<<"\b";
cout<<"\nSUM OF SERIES IS :"<<sum;
}
OUTPUT:
- Get link
- X
- Other Apps
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment