Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
33
Task/100-doors/JavaScript/100-doors-5.js
Normal file
33
Task/100-doors/JavaScript/100-doors-5.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
(function (n) {
|
||||
"use strict";
|
||||
return range(1, 100)
|
||||
.filter(function (x) {
|
||||
return integerFactors(x)
|
||||
.length % 2;
|
||||
});
|
||||
function integerFactors(n) {
|
||||
var rRoot = Math.sqrt(n),
|
||||
intRoot = Math.floor(rRoot),
|
||||
lows = range(1, intRoot)
|
||||
.filter(function (x) {
|
||||
return (n % x) === 0;
|
||||
});
|
||||
return lows.concat(lows.map(function (x) {
|
||||
return n / x;
|
||||
})
|
||||
.reverse()
|
||||
.slice((rRoot === intRoot) | 0));
|
||||
}
|
||||
function range(m, n, delta) {
|
||||
var d = delta || 1,
|
||||
blnUp = n > m,
|
||||
lng = Math.floor((blnUp ? n - m : m - n) / d) + 1,
|
||||
a = Array(lng),
|
||||
i = lng;
|
||||
if (blnUp)
|
||||
while (i--) a[i] = (d * i) + m;
|
||||
else
|
||||
while (i--) a[i] = m - (d * i);
|
||||
return a;
|
||||
}
|
||||
})(100);
|
||||
Loading…
Add table
Add a link
Reference in a new issue