본문 바로가기

[BOJ] - JAVA

[백준] 8393 : 합 JAVA 풀이

import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int sum = 0;
        while(N>0){
            sum += N;
            N--;
        }
        System.out.println(sum);
    }
}