原始碼:http://down.gogobox.com.tw/t2329175/wq2m2
'質數判斷
Private Sub Form_Load()
Dim Num As Long, f As Boolean
Do
Num = Val(InputBox("請輸入一個要判斷的正整數", ""))
f = True
x = Num \ 2
For i = 2 To x
If (Num Mod i = 0) Then
f = False
Exit For
End If
Next
If f = True Then MsgBox "是質數", 15, "" Else MsgBox "不是質數", 15, ""
Loop While MsgBox("再來一次嗎?", vbYesNo, "") = vbYes
End
End Sub


讓地獄深紅的天亮 發表在 痞客邦 PIXNET 留言(0) 人氣()