Description
给出一整数n,输出sum(n)=1+2+…+n的值
Input
多组输入,每组用例占一行为一整数n
Output
输出sum(n)的值,每组输出后跟一空行
Sample Input
1
100
Sample Output
1
5050
Solution
n过大,可以用double代公式过
Code
#include <stdio.h>
int main()
{
double n;
while (~scanf("%lf",&n))
printf("%d\n\n",(int)(n*(n+1)/2));
return 0;
}