Computer Science, asked by harijanbasanti41, 5 months ago

write JavaScript to input a number and print all it's factors​

Answers

Answered by kabirgk30
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