Home  • Programming • JavaScript

Prime number with JavaScript

<script>
	var x=parseInt(prompt("Enter the number",""))
	
      prime=1;
      for(var i=2;i<=x-1;i++)	{
			
          if(x%i==0){
            prime=0;
            break;
           }
	
       } 

    if(prime){
        document.write("Prime");

    }else{

      document.write("Not prime");
   }
	
</script>
About Author
MD. IQBAL HOSSAIN
Copyright © 2024. Powered by Intellect Software Ltd