计算素数

来源:百度知道 编辑:UC知道 时间:2024/03/29 22:43:26
计算1391391399100至200之间100个数中所有的素数,最好以编程形式告诉我 谢谢
王吉生 吉林
希望全一点 而且最后能有所得素数的准确答案

test.html
<!---------------------------->

<html xmlns="http://www.w3.org/1999/xhtml">

<script language="vbscript">
Dim Line : Line=0

Function isPrime(a)
Dim j
isPrime = 0
For j = 2 To a / 2
If a Mod j = 0 Then Exit For
Next
If j > a / 2 Then isPrime = 1
End Function

Function chkNum(n)
If isPrime(n) Then
document.write(n & " ")
Line=Line+1
If Line Mod 10 < 1 Then document.write(vbCrlf)
End If
End Function

document.write( "<xmp>")
Dim nStar
Dim nEnd
nStar=0
nEnd=10000

For i=nStar To nEnd Step 10
chkNum(i+1)
chkNum(i+3)
chkNum(i+5)
chkNum(i+7)
chkNum(i+9)
Next
//-->
</SCRIPT>

要什么样的?VB?C?Java?