3个回答
2013-07-31
展开全部
Private Sub Command2_Click()
For i = 1 To 100
If prime(i) Then Print i
Next
End SubPublic Function prime(ByVal m As Integer) As Boolean '鍒ゆ柇m鏄�惁涓虹礌鏁?
Dim b As Boolean
Dim i As Integer
b = True
For i = 2 To Sqr(m)
If m Mod i = 0 Then
b = False
Exit For
End If
Next i
prime = b
End Function
For i = 1 To 100
If prime(i) Then Print i
Next
End SubPublic Function prime(ByVal m As Integer) As Boolean '鍒ゆ柇m鏄�惁涓虹礌鏁?
Dim b As Boolean
Dim i As Integer
b = True
For i = 2 To Sqr(m)
If m Mod i = 0 Then
b = False
Exit For
End If
Next i
prime = b
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-07-31
展开全部
Private Sub Command1_Click()
Cls
For i = 2 To 100
j = i \ 2
Do While j >= 2
If i Mod j = 0 Then Exit Do
j = j - 1
Loop
If j = 1 Then Print i
Next i
End Sub
Cls
For i = 2 To 100
j = i \ 2
Do While j >= 2
If i Mod j = 0 Then Exit Do
j = j - 1
Loop
If j = 1 Then Print i
Next i
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询