#include <iostream>
using namespace std;
class name
{
private:
int p;
public:
int sum(int n);
};
int name::sum(int n)
{
if(n==0)
return 0;
else
return (sum(n-1)+n);
}
int main()
{
name ob;
int a;
while(cin>>a)
{
cout<<ob.sum(a)<<endl;
}
return 0;
}
using namespace std;
class name
{
private:
int p;
public:
int sum(int n);
};
int name::sum(int n)
{
if(n==0)
return 0;
else
return (sum(n-1)+n);
}
int main()
{
name ob;
int a;
while(cin>>a)
{
cout<<ob.sum(a)<<endl;
}
return 0;
}
No comments:
Post a Comment