js函数判断一百到两百以内的质数
<!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>
function fn(n){
var flag=true;
for ( var i=2 ;i<=n-1 ;i++ ){
if(n%i===0){
flag=false;
break
}
}
if(flag){
console.log(n+'是质数');
}
}
for ( var i=100 ;i<=200 ;i++ ){
fn(i);
}
</script>
</body>
</html>