Run
<html> <body> <script> function PrimeNo() { var i,flag=0; var n=prompt("enter a number"); for(i=1;i<=n;i++) { if(n%i==0) { flag+=1; } } if(flag==2) { document.write(n+" is prime number"); } else{ document.write(n+" is not a prime number"); } } </script> <form> <input type="button" value="prime number" onclick="PrimeNo();"> </form> </body> </html>