<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
for (var i=3;i<=100;i++){
var flag=true;
for(var j=2;j<i;j++){
if(i%j===0){
flag=false
}
}
if(flag){
console.log(i+'是质数')
}
else{
console.log(i+'不是质数')
}
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
var num=20;
var flag=true;
for (var i=2;i<num;i++ ){
if(num %i ==0){
flag=false
}
}
flag ? console.log(num+'是质数'):console.log(num+'不是质数')
</script>
</body>
</html>