VB编程判断一个数是否为素数

2024-11-03 03:38:29
推荐回答(1个)
回答1:

Private
Sub
Command1_Click()
a
=
Val(InputBox("ÇëÊäÈëÒ»¸öÕûÊý"))
For
i
=
2
To
Sqr(a)

If
a
Mod
i
=
0
Then
Exit
For
Next
i
If
i
>
Sqr(a)
Then
MsgBox
a
&
"亩闷Ê衡知ÇËØÊý"
Else
MsgBox
a
&
"²»ÊÇËØÊý"
End
Sub
窗口上放一个按钮,点击按钮输迅拦弯入整数即可