문제링크 : 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++) //left=13,right 17
{
int a=0; // 약수개수
for(int j=1;j<=i;j++){ //i=13
if(i%j==0) // i=13 ,j=1,13; 나머지는 0
{
a++; // a=2;
}
}
if(a%2==0)
{
answer+=i;
}
else
{
answer-=i;
}
}
return answer;
}
}