입력 예시
55

 

출력 예시
10
0+1+2+3+4+5+6+7+8+9+10

 

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int total = 0;
        for (int i=0; i<=a; i++){
            total+=i;

            if(total == a || total > a){
                System.out.println(i);
                break;
            }
        }
    }
}

복사했습니다!