编写程序,计算1到100之间所有质数的和(数学题)

来源:学生作业学帮网 编辑:学帮网 时间:2024/05/14 03:04:29

编写程序,计算1到100之间所有质数的和(数学题)

Public Sub qqqqq()
Dim i As Integer
Dim j As Integer
Dim s As Integer
Dim C As Boolean
s = 0
For i = 2 To 100
C = False
For j = 2 To i - 1
If i Mod j = 0 Then
C = True
Exit For
Else
End If
Next
If C = False Then
s = s + i
Debug.Print i
End If
Next
Debug.Print s
End Sub