close





程式碼:
Private Sub Command1_Click()
a = Val(InputBox("輸入一個正整數"))

If a >= 2 Then
msg = "1~" & a & "之間的質數有" & vbCr & "2" & vbCr

End If

For i = 1 To a Step 2
x = 0
For j = 1 To i
If i Mod j = 0 Then x = x + 1
Next j
If x = 2 Then msg = msg & i & vbCr
Next i

MsgBox msg

End Sub
arrow
arrow
    全站熱搜

    愛爾 發表在 痞客邦 留言(0) 人氣()