
write a html page with javascript to check a number is prime or not.

Hi Friend,
Try the following code:
<script type="text/javascript">
function check(){
var num=document.getElementById('num').value;
var i=2;
var b;
var status = true;
while(i<num)
{
b=num%i;
if(b==0)
{
status = false;
break;
}
i++;
}
if (status)
{
alert("Your number is a prime number");
}
else
{
alert("Your number is not a prime number");
}
}
</script>
Enter Number to Check:<input type="text" id="num"><input type="button" value="Check" onclick="check();">
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.