发布网友 发布时间:2022-04-21 06:15
共3个回答
热心网友 时间:2023-11-06 11:56
dim i,j,x
for i=3 to 100
x=1
for j=2 to i-1
if i mod j=0 then x=0
next j
if x=1 then print i
next i
热心网友 时间:2023-11-06 11:57
Private Sub Command2_Click()
For i = 1 To 100
If prime(i) Then Print i
Next
End SubPublic Function prime(ByVal m As Integer) As Boolean '鍒ゆ柇m鏄�惁涓虹礌鏁?
Dim b As Boolean
Dim i As Integer
b = True
For i = 2 To Sqr(m)
If m Mod i = 0 Then
b = False
Exit For
End If
Next i
prime = b
End Function
热心网友 时间:2023-11-06 11:57
Private Sub Command1_Click()
Cls
For i = 2 To 100
j = i \ 2
Do While j >= 2
If i Mod j = 0 Then Exit Do
j = j - 1
Loop
If j = 1 Then Print i
Next i
End Sub