求100到200之间的孪生素数及共有多少对?
1个回答

Private Sub Command1_Click()

Dim A(100) As Integer

Dim N As Integer

Dim i As Integer, j As Integer, x As Integer

For i = 100 To 200

x = 0

For j = 2 To i - 1

If i Mod j = 0 Then x = 1

Next j

If x = 0 Then

A(N) = i

N = N + 1

End If

Next i

Dim Ncont As Integer

For i = 0 To N - 1

If A(i + 1) - A(i) = 2 Then

Print A(i) & ";" & A(i + 1)

Ncont = Ncont + 1

End If

Next

Print "对数=" & Ncont

End Su