Thursday, 14 December 2017

Prime Number

Find out whether number is prime or not using HTML and JAVASCRIPT



Program:

<html>
<head>
<script type="text/javascript">
function greater()
{
var a=prompt("enter one no:");
var i;
var n=0;
for(i=1;i<=a;i++)
{
if(a%i==0)
{
n++;
}
}
if(n==2)
{
document.write("prime");
}
else
{
document.write("not prime");
}
}
</script>
<body>
<input type="buttononclick="greater()value="Find out whether number is prime or not"> 
</body>
</html>


OUTPUT:

Click in Button

Enter The Number 

See the Output

No comments:

Post a Comment