用VB编程序验证哥德巴赫猜想,即一个大于等于6的偶数可以表示为两个素数之和
题目
用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
求修正
答案
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
最新试题
热门考点