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>
标签:function,质数,js,两百,flag,var,true 来源: https://www.cnblogs.com/cengzhuquan/p/13897197.html