Private Function isprime(n As Integer) As Boolean
Dim i As Integer
isprime = True
For i = 2 To Sqr(n)
If n Mod i = 0 Then
isprime = False
Exit For
End If
Next i
End Function
Private Sub Command1_Click()
Dim i As Integer
Text1 = ""
For i = 2 To 100
If isprime(i) And isprime(i + 2) Then
Text1 = Text1 & i & "," & i + 2 & vbCrLf
End If
Next
End Sub
已发,请采纳