Skip to content

Commit b16b6a6

Browse files
authored
Add 숫자의-표현.js
1 parent 53fd37e commit b16b6a6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

level-2/숫자의-표현.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,22 @@ function solution(n) {
3131
}
3232
}
3333
return answer;
34-
}
34+
}
35+
36+
//정답 3 - yongchanson
37+
function solution(n) {
38+
/*
39+
정답 = n의 홀수 약수의 개수
40+
15의 홀수 약수 : 1,3,5,15
41+
1+2+3+4+5=15 (중간값 3)
42+
4+5+6=15 (중간값 5)
43+
7+8=15 (연속된 값)
44+
15=15 (15)
45+
*/
46+
let result = 0;
47+
48+
for (let i = 1; i <= n; i++) {
49+
if (n % i == 0 && i % 2 == 1) result++;
50+
}
51+
return result;
52+
}

0 commit comments

Comments
 (0)