Skip to content

Commit 952ddb9

Browse files
committed
순서쌍의 갯수 / 기초
1 parent fb13521 commit 952ddb9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function solution(n) {
2+
let queue = [];
3+
let count = 0;
4+
for(let i = 1; i <= Math.sqrt(n); i++) {
5+
if(n % i === 0) {
6+
queue.push(i);
7+
}
8+
}
9+
while(queue.length > 0) {
10+
const num = queue.shift();
11+
const pair = n / num;
12+
13+
if(num === pair) {
14+
count++;
15+
} else {
16+
count += 2;
17+
}
18+
}
19+
20+
return count;
21+
}

0 commit comments

Comments
 (0)