Skip to main content

Featured

functions in Python

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:

Comments

Popular Posts