Skip to content

Commit 4c9ddcc

Browse files
committed
feat(5178): ✨整理 5178
1 parent b1fabc2 commit 4c9ddcc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Rank/181/5178/solution1.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const sumFourDivisors = nums => {
2+
let ans = 0;
3+
for (let i = 0; i < nums.length; i++) {
4+
const temp = help(nums[i]);
5+
if (temp.size === 4) {
6+
ans += Array.from(temp.values()).reduce((a, b) => a + b, 0);
7+
}
8+
}
9+
return ans;
10+
}
11+
12+
function help(num) {
13+
const max = Math.floor(Math.sqrt(num));
14+
const ans = new Set();
15+
let min = 1;
16+
while (min <= max) {
17+
if ((num / min) % 1 === 0) {
18+
ans.add(min);
19+
ans.add(num / min);
20+
}
21+
min++;
22+
}
23+
return ans;
24+
}

0 commit comments

Comments
 (0)