用VB编程序验证哥德巴赫猜想,即一个大于等于6的偶数可以表示为两个素数之和尽量别用太复杂高端的语句,我们很多都没学过Private Sub Form_Click()Dim a As Long,b As Long,c As Long,i As Long,t As Longc = a - bDoa = Val(InputBox("输入不小于6的偶数"))Loop Until a >= 6 And a Mod 2 = 0If (b = 2 Or b = 3) And (c = 2 Or c = 3) ThenPrint a + "=" + b + "+" + cElseFor i = 2 To Sqr(b)If b Mod i = 0 ThenFor t = 2 To Sqr(c)If c Mod t = 0 Then Print a + "=" + b + "+" + cNext tNext iIf i > Sqr(b) ThenIf t > Sqr(c) Then Print a + "=" + b
用VB编程序验证哥德巴赫猜想,即一个大于等于6的偶数可以表示为两个素数之和
尽量别用太复杂高端的语句,我们很多都没学过
Private Sub Form_Click()
Dim a As Long,b As Long,c As Long,i As Long,t As Long
c = a - b
Do
a = Val(InputBox("输入不小于6的偶数"))
Loop Until a >= 6 And a Mod 2 = 0
If (b = 2 Or b = 3) And (c = 2 Or c = 3) Then
Print a + "=" + b + "+" + c
Else
For i = 2 To Sqr(b)
If b Mod i = 0 Then
For t = 2 To Sqr(c)
If c Mod t = 0 Then Print a + "=" + b + "+" + c
Next t
Next i
If i > Sqr(b) Then
If t > Sqr(c) Then Print a + "=" + b + "+" + c
End If
End If
End Sub
求修正