用VB编写求从100到1000的所有素数,每10个数占一行

2024-11-18 19:41:36
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim n, i, s As Integer
For n = 100 To 1000
i = Int(Sqr(n))
s = 2
w = 0
While s <= i And w = 0
If n Mod s = 0 Then
w = 1
Else
s = s + 1
End If
Wend
If w = 0 Then
Print n;
m = m + 1
If m Mod 10 = 0 Then Print
End If
Next n
End Sub