杭電acm 1001
阿新 • • 發佈:2019-01-04
import java.util.Scanner;
/**
* 求sum(n)的值
*
* @author cwx
*
*/
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n=0,sum=0;
while(scanner.hasNext()){
n=scanner.nextInt();
for(int i=1;i<=n;i++)
sum+=i;
System.out.println(sum);
System.out.println();
sum=0;
}
}
}
/**
* 求sum(n)的值
*
* @author cwx
*
*/
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n=0,sum=0;
while(scanner.hasNext()){
n=scanner.nextInt();
for(int i=1;i<=n;i++)
sum+=i;
System.out.println(sum);
System.out.println();
sum=0;
}
}
}