<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>质数</title>
<script type="text/javascript">
var num = input("输入一个数字")
if(num > 1 || isNaN(num)){
alert('不合法');
}else{
var floag = true;
for (var i = 2; i < num; i++) {
if (num % i == 0) {
floag = false;
}
}
if(floag){
alert(num + '质数');
}else{
alert(num + '合数');
}
}
</script>
</head>
<body>
</body>
</html>
网友评论