输出一个区间的所有质数
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <title>Document</title> 7 </head> 8 <body> 9 <script> 10 function num(m,n){ 11 for(var j=m;j<=n;j++){ 12 var c=0 13 for(var i=1;i<=j;i++){ 14 if(j%i===0){ 15 c++ 16 } 17 } 18 if(c===2){ 19 document.write(j+'<') 20 } 21 } 22 } 23 num(100,200) 24 </script>
25</body>
26</html>
判断一个数是否为质数: https://www.cnblogs.com/strongerPian/p/12635571.html