Private Sub Command1_Click()
Dim i,j As Long
for i=100 to 999
If prime(i) Then j=j+1
next
print j
End Sub
Private Function prime(ByVal n As Long) As Boolean '返回值=True是素数,False不是素数
Dim k As Long
If n < 2 Then
prime = False
Else
prime = True
For k = 2 To n - 1
If (n Mod k) = 0 Then prime = False: Exit For
Next k
End If
End Function