Run
<html> <body> <form name="f1"> enter the table <input type="number" name="no"> <input type="button" value="output" onclick="PrimeNo()" value="output"> </form> <p id="prime">output here</p> <script> function PrimeNo() { var i,flag=0; var p=" "; var a=parseInt(document.f1.no.value); for(i=1;i<=a;i++) { if(a%i==0) { flag+=1; } if(flag==2) {p=a+" is prime number"; } else{ p=a+" is not a prime number";} } var d=document.getElementById("prime").innerHTML=p; } </script> </body> </html>