如何求100以内的孪生素数

来源:互联网 发布:lmfao什么意思网络用语 编辑:程序博客网 时间:2024/03/28 23:50

Private Sub Form_Click()

f2 = True
p = 3
For i = 5 To 97 Step 2
For j = 2 To Sqr(i)
If i Mod j = 0 Then Exit For
Next j
If j > Sqr(i) Then f2 = True Else f2 = False
If f2 = True And i - p = 2 Then
Print i - 2, i
End If
If j > Sqr(i) Then p = i
Next i 

End Sub