请求优化或者改写成其他语言的快速程序
代码如下:Public Function tuzis(sa As String) As String 'tuzi shulie
Dim A, B, c
A = Val(sa)
B = 1
B1 = 0
b2 = 1
b3 = 0
Do While B <= A
B1 = b2
s1 = s1 & "/" & Trim(b3)
b2 = b3
b3 = MPC1(Trim(B1), Trim(b2))
B = Val(B + 1)
Loop
tuzis = s1
End Function
Private Sub Command1_Click()
Dim A, B, ak()
A = Val(Text1)
B = tuzis(Val(A))
B1 = ksm2(Val(664))
s105 = Split(B, "/")
j1 = UBound(s105)
For k = 1 To j1
n1 = n1 + 1
ReDim Preserve ak(1 To n1)
ak(n1) = s105(n1)
Next
For I = 18 To j1 - 3
A = ak(I)
B = ak(I + 1)
c = ak(I + 2)
x = MPC1(MPC1(MbC(Trim(A), Trim(B)), Trim(c)), Trim(B1))
Y = MPC1(MPC1(MbC(Trim(c), Trim(B)), Trim(A)), Trim(B1))
z = MPC1(MPC1(MbC(Trim(A), Trim(c)), Trim(B)), Trim(B1))
X1 = MPC1(Trim(x), 2)
Y1 = MPC1(Trim(Y), 2)
z1 = MPC1(Trim(z), 2)
Do While Val(js) <= 10
js = Val(js + 1)
If zhengchuqyushu(MCC(Trim(x), 3)) > 1 Or zhengchuqyushu(MCC(Trim(Y), 3)) > 1 Or zhengchuqyushu(MCC(Trim(z), 3)) > 1 Then
If nStr(fenjieyinzi0(Trim(x)), "*") = 0 And InStr(fenjieyinzi0(Trim(X1)), "*") = 0 Then
s = s + 1
s1 = s1 & "/" & s & " /" & x & "/" & X1 & vbCrLf
ElseIf InStr(fenjieyinzi0(Trim(Y)), "*") = 0 And InStr(fenjieyinzi0(Trim(Y1)), "*") = 0 Then
s = s + 1
s1 = s1 & "/" & s & " /" & Y & "/" & Y1 & vbCrLf
ElseIf InStr(fenjieyinzi0(Trim(z)), "*") = 0 And InStr(fenjieyinzi0(Trim(z1)), "*") = 0 Then
s = s + 1
s1 = s1 & "/" & s & " /" & z & "/" & z1 & vbCrLf
Else
s = s
End If
End If
x = MPC1(Trim(x), 2)
Y = MPC1(Trim(Y), 2)
z = MPC1(Trim(z), 2)
X1 = MPC1(Trim(x), 2)
Y1 = MPC1(Trim(Y), 2)
z1 = MPC1(Trim(z), 2)
Loop
Next
If s > 0 Then
Text2 = s1
Else
Text2 = "wu jie"
End If
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
End Sub
Private Function ksm2(sa As String) As String '2的快速幂程序
Dim A, B
A = Val(2): B = sa
If B = 1 Then
ksm2 = A
ElseIf B = 0 Then
ksm2 = 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
ksm2 = MbC(Trim(a3), Trim(a1))
Else
ksm2 = a3
End If
s3 = Len(ksm2)
ksm2 = ksm2
End If
End Function