<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>素数</title>
</head>
<body>
<script language="javascript">
function isPrime(n){
for(var i=2;i<=Math.sqrt(n);i++){
if(n%i==0)
return false
return true
}
}
var n=prompt("input a number:","");
if(isPrime(n)){
document.write("the number is a prime");
}
else
document.write("the number is not a prime");
</script>
</body>
</html>
来源:CSDN
作者:隔壁郑同学
链接:https://blog.csdn.net/weixin_44517301/article/details/103505022