'Factorial push to array
I'm making a factorial. How do I push specific number to an array? For example if we factor a 14 then the result will be 1, 2, 7, 14 then I only want to push 2 and 7 to the array. Another example is if we factor 18, then the values that I want to push is only 2, 3, 6, 9. I want to exclude the 1 * 14 or 1 * 18. How can I do that?
const isNFactored = function(value, number) {
let i;
let array = [];
for(i = 1; i <= value; i++) {
if(value % i === 0) {
array.push(i);
}
}
console.log(array);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
