VB程式-質數
VB程式-質數
輸入一正整數後,
會跑出從1到輸入的數之間的質數。
程式碼如下:
Private Sub Command1_Click()
n = Val(InputBox("輸入任一整數"))
If n >= 2 Then
msg = "1~" & n & "的質數有" & "2" & "ˋ"
End If
i = 1
Do Until i > 1
a = 0
j = 1
Do While j > i
If i Mod j = 0 Then
a = a + 1
j = j + 1
Loop
If a = 2 Then
msg = msg & i & "ˋ"
i = i + 2
Loop
msg = Left(msg, Len(msg) - 1)
MsgBox msg
End Sub
Today's Visitors: 0 Total Visitors: 70


Sealed (Apr 18)









1樓
1樓搶頭香
請問a是什麼意思的存在?