factor chain in javascript code example
Example 1: javascript factor chain
function factorChain(arr) {
for (let i = 0; i < arr.length - 1; i++) {
if ((arr[i + 1] % arr[i]))
return false
}
return true
}
Example 2: javascript factor chain
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]