function factorChain(arr) {
for (let i = 0; i < arr.length - 1; i++) {
if ((arr[i + 1] % arr[i]))
return false
}
return true
}
const factors = number => Array
.from(Array(number + 1), (_, i) => i)
.filter(i => number % i === 0)
console.log(factors(36)); // [1, 2, 3, 4, 6, 9, 12, 18, 36]
const factors = number => [...Array(number + 1).keys()].filter(i=>number % i === 0);
console.log(factors(36)); // [1, 2, 3, 4, 6, 9, 12, 18, 36]
function factorChain(num) {
let n = num.slice(num.length - 1, num.length)[0]
return [...Array(n + 1).keys()]
.filter(v => n % v === 0)
.map((v, i) => v === num[i])[0]
}
function calculate(num) {
var str = "0";
for (var i = 1; i <= num; i++) {
if (num % i == 0) {
str += ',' + i;
}
}
alert(str);
}
calculate(232);
function factorChain (arr) {
return arr.reduce((a, c, i) => arr[i] % arr[i-1] === 0);
}