class Solution {
public long solution(int a, int b) {
long answer = 0;
int tmp;
if (a > b) {
tmp = a;
a = b;
b = tmp;
}
while (a <= b) {
answer += a;
a++;
}
return answer;
}
}
'프로그래머스' 카테고리의 다른 글
프로그래머스 - 모의고사 (0) | 2019.01.07 |
---|---|
프로그래머스 - 짝수와 홀수 (0) | 2019.01.07 |
프로그래머스 - 수박수박수박수박수박수? (0) | 2019.01.07 |
프로그래머스 서울에서 김서방 찾기 (0) | 2019.01.07 |
프로그래머스 - 완주하지 못한 선수 (0) | 2019.01.05 |