vb编程题 输出3到100之间所有的质数 (质数:只能被1和它本身整除的数)

2024-11-27 04:22:05
推荐回答(2个)
回答1:

Private Sub Command1_Click()
For i = 3 To 100
For j = 2 To Sqr(i)
If i Mod j = 0 Then Exit For
Next
If j > Int(Sqr(i)) Then s = s & i & " "
Next
MsgBox s
End Sub

回答2:

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97