再发一下那3个可调用程序:(辗转相除法,求乘法逆元,快速幂模计算程序)
Private Function zzxc(sa As String, sb As String) As String
Dim a, B, c, d, r
a = Trim(sa)
B = Trim(sb)
If Len(a) < 10 And Len(B) < 10 Then
If Val(a) > Val(B) Then
c = a
d = B
Else
c = B
d = a
End If
Do Until Val(c) Mod Val(d) = 0
r = c Mod d
c = d
d = r
Loop
Else
If MBJC(Trim(a), Trim(B)) >= 1 Then
c = a
d = B
Else
c = B
d = a
End If
Do Until zhengchuqyushu(MCC1(Trim(c), Trim(d))) = 0
r = zhengchuqyushu(MCC1(Trim(c), Trim(d)))
c = d
d = r
Loop
End If
zzxc = d
End Function
Private Function qniyuan(sa As String, sb As String) As String
Dim n, p, a, B, c, d, r
n = Trim(sa)
p = Trim(sb)
a = 1
B = 0
c = 0
d = 1
If Len(n) < 10 And Len(p) < 10 Then
If Val(n) > Val(p) Then
m = n
q = p
s1 = 1
Else
m = p
q = n
s1 = 0
End If
Do Until Val(m) Mod Val(q) = 0
s = m \ q
r = m Mod q
s1 = s1 + 1
If s1 Mod 2 = 1 Then
a = a
B = a * s + B
c = c
d = c * s + d
Else
B = B
a = a + B * s
d = d
c = c + d * s
End If
m = q
q = r
Loop
If Val(a + B * m) = p Then
B = B
a = a + B * (m - 1)
d = d
c = c + d * (m - 1)
Else
If Val(B + a * m) = p Then
a = a
B = B + a * m
c = c
d = d + c * m
Else
B = B
a = a + B * (m - 1)
d = d
c = c + d * (m - 1)
End If
End If
x = (a + B) Mod p
y = (c + d) Mod n
Else
If MBJC(Trim(n), Trim(p)) >= 1 Then
m = n
q = p
s1 = 1
Else
m = p
q = n
s1 = 0
End If
Do Until zhengchuqyushu(MCC1(Trim(m), Trim(q))) = 0
s = zhengchuqy(MCC1(Trim(m), Trim(q)))
r = zhengchuqyushu(MCC1(Trim(m), Trim(q)))
s1 = s1 + 1
If s1 Mod 2 = 1 Then
a = a
B = MPC1(MbC(Trim(a), Trim(s)), Trim(B))
c = c
d = MPC1(MbC(Trim(c), Trim(s)), Trim(d))
Else
B = B
a = MPC1(Trim(a), MbC(Trim(B), Trim(s)))
d = d
c = MPC1(Trim(c), MbC(Trim(d), Trim(s)))
End If
m = q
q = r
Loop
If MPC1(Trim(a), MbC(Trim(B), Trim(m))) = p Then
B = B
a = MPC1(Trim(a), MbC(Trim(B), MPC(Trim(m), 1)))
d = d
c = MPC1(Trim(c), MbC(Trim(d), MPC(Trim(m), 1)))
Else
If MPC1(Trim(B), MbC(Trim(a), Trim(m))) = p Then
a = a
B = MPC1(Trim(B), MbC(Trim(a), Trim(m)))
c = c
d = MPC1(Trim(d), MbC(Trim(c), Trim(m)))
Else
B = B
a = MPC1(Trim(a), MbC(Trim(B), MPC(Trim(m), 1)))
d = d
c = MPC1(Trim(c), MbC(Trim(d), MPC(Trim(m), 1)))
End If
End If
Do While Left(a, 1) = "0"
a = Mid(a, 2)
Loop
End If
qniyuan = a
End Function
Private Function qksmimo(sa As String, sb As String, sc As String) As String
Dim c, e, n, d
c = Trim(sa)
e = Trim(sb)
n = Trim(sc)
d = 1
If Len(c) < 5 And Len(e) < 5 And Len(n) < 5 Then
c = Val(c): n = Val(n)
Do While e > 0
If Right(e, 1) Mod 2 = 0 Then
c = c * c Mod n
e = e / 2
Else
d = d * c Mod n
e = e - 1
End If
Loop
Else
c = c
Do While MBJC(Trim(e), 1) >= 0
If Right(e, 1) Mod 2 = 0 Then
c = zhengchuqyushu(MCC1(MbC(Trim(c), Trim(c)), Trim(n)))
e = zhengchuqy(MCC1(Trim(e), 2))
Else
d = zhengchuqyushu(MCC1(MbC(Trim(c), Trim(d)), Trim(n)))
e = MPC(Trim(e), 1)
End If
Loop
End If
qksmimo = d
End Function