| 求大于一个数的最小素数
Private Sub C1_Click() Open "in5.txt" For Input As #1 Input #1, a% Close #1 Text1.Text = a% End Sub
Private Sub C2_Click() a% = Text1.Text Do a% = a% + 1 Loop Until isprime(a%) Text2.Text = a% End Sub
Private Sub C3_Click() Open "out5.txt" For Output As #1 Print #1, Text2.Text Close #1 End Sub
Private Function isprime(a As Integer) As Boolean Dim flag As Boolean flag = True b% = 2 Do While b% <= Int(a / 2) And flag If Int(a / b%) = a / b% Then flag = False Else b% = b% + 1 End If Loop isprime = flag End Function |