In HTML 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:
Bonus +5
If the factor is Even : Print it in Green
If The Factor is Odd : Print it in Red
the HTML code with function is given below:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<p>Enter a number:</p>
<input type="text" id="inp" />
<input type="submit" onclick="factors()" value="Factors" />
<!-- here I am taking a input and then on clicking the submit button it will run the factors function -->
<p id="result"></p>
<script>
function factors() {
// in factors function I have iterated till the number and
document.getElementById("result").innerHTML = ""; // checked if any number is divible by it or not
document.getElementById("result").innerHTML = "Factors are:"; // if divisible then printed it
var num = document.getElementById("inp").value;
var count = 0; // this variable is to check wheather the factors are odd or even
for (let index = 1; index <= num; index++) {
if (num % index == 0) {
count++;
document.getElementById("result").innerHTML += index + " ";
}
if (count % 2 == 0) { // of even then i am adding the style green to it
document.getElementById("result").style.color = "green";
} else { // else style red to it
document.getElementById("result").style.color = "red";
}
}
}
</script>
</body>
</html>
FOR BETTER UNDERSTANDING PLEASE GO THROUGH THE SCREENSHOT:-

THE OUTPUT AND HTML WINDOW:-


In HTML write a program that calculates and displays all factors of a number with a...
In C++ using For Loops; "Write a program that displays number facts for a number provided by the end user between 1-100 in a table format that includes the number itself, whether the number is a prime number, whether the number is even or odd, whether the number is a perfect square and all of its factors. " It should also print this information.
Intro to Programming and Logic (chapter 5): Python 2 - Conditionals and Recursion: Write a program that will simulate a roulette wheel. The pockets on a roulette wheel are different colors. There are 36 pockets – numbered 0 to 35. Pocket 0 and 18 are green. For pockets 1 – 8, the even numbers are black and the odd numbers are red. For pockets 9 – 17, the even numbers are red and the odd numbers are black. For pockets...
1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3. Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...
<!DOCTYPE html> <html> <body> <script> // // Write a function that calculates the amount of money a person would earn over // a period of years if his or her salary is one penny the first day, two pennies // the second day, and continues to double each day. The program should ask the // user for the number of years and call the function which will return the total // money earned in dollars and cents, not pennies. Assume...
Please solve it by Python 3 Write a program that asks the user for a positive integer limit and prints a table to visualize all factors of each integer ranging from 1 to limit. A factor i of a number n is an integer which divides n evenly (i.e. without remainder). For example, 4 and 5 are factors of 20, but 6 is not. Each row represents an integer between 1 and 20. The first row represents the number 1,...
Write a C++ console application that calculates and displays the charges for multiple customers using a parking garage. The parking garage charges a minimum fee of $3.00 to park for up to three hours. The garage charges an additional $0.85 per hour or fraction of an hour for parking over three hours. The maximum charge for any given 24-hour period is $20.00. You may assume that no car parks for longer than 24 hours at a time. Your program will...
Write a program that reads from the keypad an integer and calculates the following: If the number given by the user is even, then divide it by 2. If it is an odd number, multiply it by 3 and add 1.The program should repeat this procedure for the calculated new result (which will be printed on the screen) until it reaches number 1. The program will also need to print out how many steps it took overall.
programming language: C++ *Include Line Documenatations* Overview For this assignment, write a program that will simulate a game of Roulette. Roulette is a casino game of chance where a player may choose to place bets on either a single number, the colors red or black, or whether a number is even or odd. (Note: bets may also be placed on a range of numbers, but we will not cover that situation in this program.) A winning number and color is...
A factor of an integer N is an integer that divides N evenly. Note that 1 and N are always factors of N. For this task, You will need to write a MIPS program that accepts a positive integer from the standard input, counts and reports how many factors of this integer are even and how many are odd. See the sample run below for required format. Sample runs (user input in blue): Please enter a positive int: 20 User...
HTML only Design and implement a program that calculates the amount of money a person would earn over a period of time if his or her salary is one penny the first day, two pennies the second day, and continues to double each day. The program should:ask the user for the number of daysdisplay a table showing what the salary was for each daythen show the total pay at the end of the period.The output should be displayed in the...