package com.company;
class Solution {
static public void main(String[] args) {
System.out.println((solution(13, 17)) == 43);
System.out.println((solution(24, 27)) == 52);
}
static public int solution(int left, int right) {
int answer = 0;
for (int i = left; i <= right; i++) {
int commonDivisor = getCommonDivisorNum(i);
int tempVal = i;
if( commonDivisor % 2 == 0){
}else {
tempVal = -1 * tempVal;
}
answer = answer + tempVal;
}
return answer;
}
private static int getCommonDivisorNum(int num) {
int rtVal = 0;
for (int i = 1; i < num; i++) {
if(num % i ==0 ){
rtVal++;
}
}
rtVal++;
return rtVal;
}
}