# HDU 1001

Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).

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

import java.util.*;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
int sum = 0;
for(int i =1;i<=n;i++){
sum = sum + i;
}
System.out.println(sum);
System.out.println( );
/*  if(n==0)
break;*/
}
}
}

#### HDU 1001Sum Problem（入门题，C，Java两个版本）

2016-02-23 19:05:17

#### hdu 1001 java

2014-01-21 22:45:01

#### 杭电acm 1001

2012-10-07 12:49:52

#### hdu1238Substrings

2016-08-01 15:04:33

#### HDU5971 Wrestling Match（二分图染色）

2017-05-02 11:38:25

#### 【基础编程】hdu题目分类

2016-10-10 17:07:30

#### 【2017青岛网络赛】1006 hdu 6211 Pythagoras 打表+本原勾股数

2017-09-20 21:45:14

#### 杭电ACM1001题------c语言

2016-10-03 18:52:01

#### HDU 5971 Wrestling Match 2016大连区域赛

2016-11-06 18:50:27

#### 动态规划背包问题入门

2011年07月07日 328KB 下载