Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>質數</title>
</head>
<body>
</body>
</html>
 
window.addEventListener("load",function(){
    var prime=false,i=0,num=0;
    
        
        do{
            num=Math.floor(Math.random()*10000)+1;
            if (num===2 || num==3) prime=true;
            for(i=2;i<=Math.sqrt(num);i++){
                if(num%i===0){
                    prime=false;
                    break;
                }else{
                    prime=true;
                }
            }
        }while(prime===false);
    
    window.alert(num);
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
yaoyao34pro
0viewers