Programming Homework Help
Programming Homework Help. Please just edit the code and add an input so anyone can enter the number and get the factors
Write a program that calculates and displays all factors of a number with a function. A factor is any number that divides into a number evenly.
For examples: Factors of 20 are 1,2,4,5,10,20
For the program:
- Prompt the user for a number or use an input
- Call a function to calculate all factors using loops and conditionals and modulus
- Display all factors to the page
MY CODE: note I couldn’t attach it and please complete the work on an html file and thank you
<html>
<script>
function factorize(number) {
var factors=[],i;
for (i=1;i<=number;i++) {
if (number%i==0) {
factors.push(i);
}
}
return factors;
}
document.write(“The factors of 16 are: “+factorize(16));
</script>
<body>
</body>
</html>