두 정수 사이의 합

han.user();·2023년 4월 13일
0

프로그래머스

목록 보기
67/87
post-thumbnail

class Solution {
    public long solution(int a, int b) {
        long sum = 0;

        if (a > b) {
            int temp = a;
            a = b;
            b = temp;
        }
        for (int i = a; i <= b; i++) {
            sum += i;
        }
        return sum;
    }
}
profile
I'm still hungry.

0개의 댓글