#include<iostream>
using namespace std;
int main()
{
int a;
cin>>a;
while(!cin.eof())
{
if(a%2!=0) //注意特殊情况
cout<<(a+1)/2*a<<endl<<endl;
else
cout<<a/2*(a+1)<<endl<<endl;
cin>>a;
}
}
原文:http://www.cnblogs.com/Leonsco/p/5031349.html