输出100以内的所有孪生素数.
问题描述:
输出100以内的所有孪生素数.
答
Private Sub Command1_Click()
Dim a()
For i = 100 To 1 Step -1
For j = i - 1 To 1 Step -1
If i Mod j = 0 Then n = n + 1
Next
If n = 1 Then
m = m + 1
ReDim Preserve a(m)
a(m) = i
If a(m - 1) - a(m) = 2 Then Print a(m) & Space(1) & a(m - 1) & vbCrLf
End If
n = 0
Next
End Sub