用vb编程:输出100-200之间的所有素数,并将这些数求和,求出结果存入所给变量su

2024-11-26 08:40:58
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, su As Integer
For i = 100 To 300
For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then
Exit For
End If
Next
If j > Int(Sqr(i)) Then
su = su + i
If k Mod 10 = 0 Then Print
Print Format(i, "@@@@");
k = k + 1
End If
Next
MsgBox su

End Sub