判断素数
Private Sub Command1_Click()
Dim s As Integer, k As Integer
s = CInt(Text1)
For k = 2 To Sqr(s)
If s Mod k = 0 Then
Exit For
End If
Next k
If k > Sqr(s) Then
Text2 = s & "是素数"
Else
Text2 = s & "不是素数"
End if
End sub
Private Sub Command1_Click()
Dim s As Integer, k As Integer
s = CInt(Text1)
For k = 2 To Sqr(s)
If s Mod k = 0 Then
Exit For
End If
Next k
If k > Sqr(s) Then
Text2 = s & "是素数"
Else
Text2 = s & "不是素数"
End if
End sub