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