VB编程题 求1-100内的素数个数
发布网友
发布时间:2024-02-16 19:04
我来回答
共2个回答
热心网友
时间:2024-11-24 13:02
答案:25个
Sub Command3_Click()
Dim i As Long, m As Integer, n As Integer
For i = 2 To 100
For m = 2 To i / 2
If i Mod m = 0 Then GoTo inext
Next
n = n + 1
inext:
Next
MsgBox n
End Sub
热心网友
时间:2024-11-24 13:03
Dim i, j As Integer
Dim flag As Boolean
n=0
For i = 2 To 100
flag = False
For j = 2 To i / 2
If i Mod j = 0 Then
flag = True
Exit For
End If
Next
If flag = False Then
n=n+1
End If
Next
print n