Skip to content

Commit 3e18dc1

Browse files
committed
Add 악수의-합.js
1 parent db35cbf commit 3e18dc1

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

level-1/약수의-합.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,13 @@ function solution(n) {
5151
}
5252
// 약수란 어떤 수를 나누었을 때 나머지 없이 나누어 떨어지게 하는 그 수입니다.
5353
// 10을 예로 들면, 10은 1, 2, 5, 10 이 나누었을 때 나머지가 없으므로 약수입니다.
54-
// 3, 4, 6, 7, 8, 9 는 나누었을 때 나머지가 남기때문에 약수가 아닙니다.
54+
// 3, 4, 6, 7, 8, 9 는 나누었을 때 나머지가 남기때문에 약수가 아닙니다.
55+
56+
//정답 4 - prove-ability
57+
function solution(n) {
58+
let answer = 0;
59+
for(let i = 1; i <= n; i++) {
60+
if(n % i === 0) answer += i;
61+
}
62+
return answer;
63+
}

0 commit comments

Comments
 (0)