0

i cant seem to figure out how to get the computer to know even / odd numbers using it for a prime factors. not looking for someone to do it for me just need a nudge in the right direction

create code that asks the user to supply an integer greater than 1 and then display all the prime numbers that multiply together to get the user’s number. If a number is a prime, its only factors are itself and one.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>OddsEvens</title>
</head>
<body>
<script>
var integer;
var factor;
var fn;

integer= 1;
factor= prompt ("plz instert a number greater then 1");
fn= 2;

		if (factor <= integer) {
	 			 alert ("invalid number");
}	 	if (fn / integer) == 0 ){
		 	 alert ("even");
			} 
		





</script>
</body>
</html>

Edited by bazer: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by bazer
0
var n = prompt("Check your number", "Type your number here");

n = parseInt(n);

if (n == 0)
   {
   alert("The number is zero");
   }
else if (n%2)
   {
   alert("The number is odd");
   }
else
   {
   alert("The number is even");
   }
0

thanks that part works i dont fully understand it ill post back in about 10-20

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.