Facebook
From 4ITSUZD6, 3 Years ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 46
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <title>Document</title>
  7. </head>
  8. <body>
  9.     <button onclick="as()">Is PRIME/Is not PRIME</button>
  10.     <script>
  11.         function as()
  12.         {
  13.             var x = Math.floor(Math.random()*100+1);
  14.             if(x%2 != 0 && x%3 != 0 && x%5 != 0 && x%7 != 0)
  15.             {
  16.                 console.log("Number "+x+" is prime!");
  17.             }
  18.             else if(x<10)
  19.             {
  20.             if(x == 2 || x == 3 || x == 5 || x == 7)
  21.             {
  22.                 console.log("Number "+x+" is prime!");
  23.             }
  24.             else
  25.             {
  26.                 console.log("Number "+x+" is not prime!")
  27.             }
  28.             }
  29.             else
  30.             {
  31.                 console.log("Number "+x+" is not prime!");
  32.             }
  33.         }
  34.     </script>
  35. </body>
  36. </html>