vb编写一个判断素数的通用过程调用该过程计算并输出区间【3,200】内所有素数的和

如题所述

第1个回答  2012-05-12
Private Sub Command1_Click()
Dim i As Integer
For i = 3 To 200
If MySuShu(i) Then Print i
Next i
End Sub

Private Function MySuShu(ByVal n As Integer) As Boolean
Dim i As Integer
Dim YesNo As Boolean
i = 2
YesNo = True
Do While i <= n - 1 And YesNo
If n Mod i = 0 Then YesNo = False
i = i + 1
Loop
MySuShu = YesNo
End Function本回答被提问者采纳
相似回答
大家正在搜