2.
哥德巴赫1742年给欧拉的信中提出了以下猜想:任一大于2的偶数都可写成两个质数之和,是为著名的哥德巴赫猜想。下面VB程序用来验证4-10000的偶数分解。
请完善下列程序代码:
Function prime(x As Integer) As Boolean ’此函数判断x是否为质数
prime = True
For i = 2 To Int(Sqr(x))
If Then prime = False: Exit For
Next i
End Function
Private Sub Command2_Click()
Dim a As Integer, b As Integer
Dim n As Integer
For a = 2 To n \ 2
b = n - a
If Then
List1.AddItem Str(a) + " " + Str(b) + " " + Str(n)
End If
Next
End Sub