<body>
<script language="javascript">
function panduan()
{
var k=Number(fr.num1.value);
var i=Number(fr.num2.value);
var sum=0;
var count=0;
var n=Math.sqrt(k);
while(count<i){
for(var j=2;j<n;j++){
if(k%j==0)
break;
}
if(j>n){
count++;
document.write(k+" ");
sum=he(k);
}
k++;
n=Math.sqrt(k);
}
document.write("素数之和为"+sum);
}
var s=0;
function he(k){
s=s+k;
return s;
}
</script>
<form action="" name="fr">
请输入k:<input type="text" name="num1" /><br />
请输入i:<input type="text" name="num2" /><br />
<input type="reset" value="输出素数及之和" onclick="panduan()" >
</form>
</body>