Private Sub Form_Click()
For i = 2 To 3
s = 2
For j = 2 To i - 1
If i Mod j = 0 Then
Else
s = s + i
End If
Next j
Next i
Print "素数和为" & s
End Sub
Private Sub Command1_Click() '按下
’Command1判断任意数是否被素数
x = InputBox("输入一个数")
If x = 1 Or x = 2 Then
MsgBox (x & "为素数")
Else
For k = 2 To x - 1
If x Mod k = 0 Then
MsgBox (x & "不为素数")
End
Else
If k = x - 1 Then
MsgBox (x & "为素数")
End If
End If
Next k
End If
End Sub
for i=2 to 200
if f(i) then s=s+i
print i
function f(a)
f=0
for i=2 to a
if a mod i=0 then exit function
next i
f=1
end function