https://school.programmers.co.kr/learn/courses/30/lessons/77884
class Solution {
public int solution(int left, int right) {
int answer = 0;
for(int i = left; i <= right; i++){
int num = 0; // ์ฝ์์ ๊ฐ์
for(int j = 1; j <= i; j++){
if(i % j == 0){
num++;
}
}
if(num % 2 == 0){ // ์ฝ์์ ๊ฐ์๊ฐ ์ง์๋ฉด ๋ํ๊ธฐ
answer += i;
}
else{
answer -= i; // ํ์๋ฉด ๋นผ๊ธฐ
}
}
return answer;
}
}