|

楼主 |
发表于 2022-9-1 10:34
|
显示全部楼层
代码如下:
Private Sub Command1_Click()
Dim ax
ax = Val(Text1)
ts = Timer
b = Val(Text2)
s = 0
Do While s <= b
s = s + 1
s1 = qxdcm(Trim(2), Trim(s))
p = MPC1(Trim(ax), Trim(s1))
p1 = MPC1(Trim(p), Trim(2))
If InStr(fenjieyinzi0(Trim(p)), "*") = 0 And InStr(fenjieyinzi0(Trim(p1)), "*") = 0 Then
Text3 = Text3 & ax & "+2^" & s & "," & ax + 2 & "+2^" & s & vbCrLf
s2 = s2 + 1
Else
s2 = s2
End If
Loop
Combo1 = "2^" & b & "内有" & s2 & "个孪生素数:(用时" & Timer - ts & "秒)" & Text3
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Combo1 = ""
Form1.Cls
End Sub
Private Function qxdcm(sa As String, sb As String) As String
Dim a, b
a = sa: b = sb
If b = 1 Then
qxdcm = a
ElseIf b = 0 Then
qxdcm = 1
Else
a1 = a
Do While b > 1
s = Int(Log(b) / Log(2))
s1 = 0
Do While s1 < s
a = MbC(Trim(a), Trim(a))
s1 = s1 + 1
Loop
a2 = a
b = b - 2 ^ s
a = a1
If s2 > 0 Then
a3 = MbC(Trim(a3), Trim(a2))
Else
a3 = a2
End If
s2 = s2 + 1
Loop
If b = 1 Then
qxdcm = MbC(Trim(a3), Trim(a1))
Else
qxdcm = a3
End If
End If
End Function
|
|