problem description
hey, welcome to HDOJ.
in this problem, your task is to calculate SUM(n)=1+2+3+…+n.
input
the input will consist of a series of integers n, one integer per line.
output
for each case, output SUM(n) in one line, followed by a blank line. you may assume the result will be in the range of 32-bit signed integer.
sample input
1
100
sample output
1
5050
code
#include<stdio.h>
int main()
{
int n,sum=0;
while(scanf("%d",&n)!=EOF)
{
int ans=0;
for(int i=n;i>0;i--)ans+=i;
printf("%d\n\n",ans);
}
return 0;
}