VB代码求解~~急~~谢谢~~~

来源:百度知道 编辑:UC知道 时间:2024/05/19 04:00:47
键盘输入一个正整数,找出大于或等于该数的第一个素数
写一下这个代码谢谢了~~~

Private Sub Command1_Click()
Dim i%, n%, j As Boolean
n = Val(InputBox("请输入一个正整数!"))
Print "正整数"; n
Do
For i = 2 To n - 1
If n Mod 2 = 0 Then j = True: Exit For
Next
n = n + 1
Loop Until j = True
Print "大于或等于该数的第一个素数是:"; n
End Sub