代码如下
<!DOCTYPE html
>
<html lang
="en">
<head
>
<meta charset
="UTF-8">
<meta name
="viewport" content
="width=device-width, initial-scale=1.0">
<title
>素数
</title
>
<script
>
for(i
=2;i
<100;i
++){
var k
=0;
for(j
=2;j
<100;j
++){
if(i
%j
==0){
k
++;
}
}
if(k
==1){
document
.write(i
+" ");
}
}
</script
>
</head
>
<body
>
</body
>
</html
>
结果如下
转载请注明原文地址:https://tech.qufami.com/read-838.html