# 240514

문제 : [약수의 개와 덧셈](https://school.programmers.co.kr/learn/courses/30/lessons/77884)\
난이도 : Lv.1\
설명 :

> 두 정수 left와 right가 매개변수로 주어집니다. left부터 right까지의 모든 수들 중에서, 약수의 개수가 짝수인 수는 더하고, 약수의 개수가 홀수인 수는 뺀 수를 return 하도록 solution 함수를 완성해주세요.

## 풀이

```javascript
function solution(left, right) {
    let answer = 0

    for(let i = left; i <= right; i++) {
        let count = 0;

        for(let j = 1; j <= i; j++) {
            if(i % j === 0) {
                count++
            }
        }

        if (count % 2 === 0) {
            answer += i;
        } else {
            answer -= i;
        }    
    }

    return answer
}
```

## 👀 다른 사람 풀이

```javascript
function solution(left, right) {
    var answer = 0;
    for (let i = left; i <= right; i++) {
        if (Number.isInteger(Math.sqrt(i))) {
            answer -= i;
        } else {
            answer += i;
        }
    }
    return answer;
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jiwons-organization.gitbook.io/jiwon0995/dev-note/index-8/240514.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
