write JavaScript to input a number and print all it's factors
Answers
Answered by
0
Answer:
// program to find the factors of an integer
// take input
const num = prompt('Enter a positive number: ');
console.log(`The factors of ${num} is:`);
// looping through 1 to num
for(let i = 1; i <= num; i++) {
// check if number is a factor
if(num % i == 0) {
console.log(i);
}
}
Explanation:
Similar questions
History,
2 months ago
Computer Science,
5 months ago
French,
5 months ago
Math,
10 months ago
Social Sciences,
10 months ago