|

楼主 |
发表于 2023-2-17 09:38
|
显示全部楼层
Private Sub Command1_Click()
'验证素数的原根的程序
Dim a, b
a = Trim(Text1)
jB = Trim(Text2)
jB1 = qxdcm(2, 4)
g = 10
c = MCC1(MPC(Trim(a), 1), Trim(jB))
C1 = MCC1(MPC(Trim(a), 1), Trim(jB1))
j = qksmimo(Trim(g), Trim(jB), Trim(a))
j1 = qksmimo(Trim(g), Trim(c), Trim(a))
j2 = qksmimo(Trim(g), Trim(C1), Trim(a))
If j <> 1 And j1 <> 1 And j2 <> 1 Then
Text3 = g & "是该素数的原根,素数是 " & a
Else
Text3 = g & "不是原根"
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Combo1 = ""
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 |
|