We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 890aeb9 commit d43e96bCopy full SHA for d43e96b
1390-four-divisors.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * @param {number[]} nums
3
+ * @return {number}
4
+ */
5
+var sumFourDivisors = function(nums) {
6
+ let res = 0
7
+
8
+ for(const e of nums) {
9
+ const set = helper(e)
10
+ if(set.size === 4) {
11
+ for(const i of set) res += i
12
+ }
13
14
15
+ return res
16
17
+ function helper(num) {
18
+ const set = new Set()
19
+ const r = ~~(Math.sqrt(num) + 1)
20
+ for(let i = 1; i < r; i++) {
21
+ if(num % i === 0) {
22
+ set.add(i)
23
+ set.add(num / i)
24
25
26
+ return set
27
28
+};
0 commit comments