求整数的幂:
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 & " 位"
erase a()
erase s()
end sub
630579487001782335726002615792364094952165878414343610620052345960454000623869717150110134871530406526506596116621245692979780766018454723814941962225280444496680617986892514285389144879868315356003294016268897967389615776485793286944718984742918155008669160686304394046689980772947571955818313574524053261334280151435474048213519731874464008804365682389586791274105235358818815781558634177999971887863992158897446085044123998978046463312787515180116167648729645857420185283426852765196485647629155480382695950964878246182512241779417530644366508296359890621342374743216814827298677837537127191389325078789702161244755212399071022208336288737320260669289128618363837680219125084636139500779965085831721640867438122082462575279544168944143807852182258001494675170105254593973657504895409323103589111263340101457860479633052538616499311242755803364866160690679932450546437333357801314944297615473518989151906689225640218032168511843254194475054735008588057580564616708627171314609458370995184597065870225908848090609713158371
205008197360061232451962937688497529185472891365374205366335638167903354851268543866741594606404778534413170189227201660243619326967118038553371962949277208611272730183912256392169184870667944551006135610198093987592067804976863451816862307886633527590311207052252043768778150433169161733611555938489871782963975066190929234551131559841571219089936524902467554784865684002055438864764444866339943612895772503011311879159691376482427895403915622449283749625756784860338788476681740004728579641442965642959564639766764223515787186952827717731160511307110493718870865880919337618540298533991930633466084027065359489961390152286370116858912107273055560580787851459733197677294187776832842097078060202022027347770889453004485643650680648932007300960564393886467917909904960608783438777615763283775134863267945078612456538772448826813203861043025279711593925705041327141571011507971121651524792216109781980914617019822750999131251863238026170615386840438148569702786906933865851274638343385712046219029162571509363027869055435730
429085517055505659390078597470099763987912665827381967222100517688361911856562045550699068370204358486041799652466496393629809823547446470487340163837893911386650403512201648508514369963595551391277057079056399608836947379823991414202398077695031343888053980166397119815825596216497179187835606569972936688490082772885423435897296247583846518281709817002372094259257011911186860161020695498338152117586282747593184230597682546827932485961426050591031324727399771913073074886381694159602268208287932011921621806836029797523144542603011403542435848724279434874580651513120987385224015560826922143758960084850481616008702812955429370561216593625952988573764377424493879680124881777948955602646146818522247226121416516490230029247021413959149857206863559755840857958622848452696631033480008424661993996267616639944950038417398789125641585062459314158580332645047644732026367338770546419253569114214636696123272197993104943714146812596980001652585063539583682492579141200588415959421399867466637018438917328027676700294241110305