T.I.L
[24.05.23] 내일배움캠프 27일차 JAVA TIL - 프로그래머스 약수의 개수와 덧셈
HS DEVELOG
2024. 5. 24. 09:18
오늘 한 일
- 2주차 resttamplate
- 2주차 엔티티 강의 수강
class Solution {
public int solution(int left, int right) {
int answer = 0;
for(int i= left; i <= right;i++){
int cnt = 0;
for(int x = 1; x<=i;x++)
if(i%x == 0){
cnt++;
}
if(cnt%2==0){
answer += i;
}
else{
answer -= i;
}
}
return answer;
}
}