Private Sub Command1_Click() power 64, 10000'''' 64^10000 End Sub
Sub power(ByVal x As Long, ByVal n As Integer, Optional ByRef result As String) Dim a() As Long, s() As String, i As Long, temp As Long ReDim a(1 To 1) a(1) = 1 k = 0 stimer = Timer Do While k < n k = k + 1 temp = UBound(a) For i = 1 To temp a(i) = a(i) * x Next
ReDim Preserve a(1 To temp + Len(CStr(x)))
For i = 1 To UBound(a) - 1
temp = a(i) \ 10 a(i) = a(i) Mod 10 a(i + 1) = a(i + 1) + temp Next
temp = UBound(a) If a(temp) = 0 Then ReDim Preserve a(1 To temp - 1) Loop
temp = UBound(a) ReDim s(1 To temp) For i = 1 To temp s(i) = a(temp + 1 - i) Next
result = Join(s, "") Debug.Print result Debug.Print x & "^" & n & " : 用时 "; Timer - stimer & " 秒, 结果 " & temp & " 位"