Smallest Ten Digit Powers

This is a companion piece of Largest Ten Digit Powers. The codes are almostly same,with a few changes only.

  1. Functionbefit(ByValsAsString,ByValnumAsLong)AsBoolean'tellifastringscontainalldigit(0-9)forjustnumtimes
  2. Dimb(9)AsLong,tAsLong
  3. befit=True'init
  4. IfLen(s)<>10*numThenbefit=False:ExitFunction
  5. Fori=1ToLen(s)
  6. t=Val(Mid(s,i,1))
  7. b(t)=b(t)+1
  8. Ifb(t)>numThenbefit=False:ExitFunction
  9. Next
  10. EndFunction
  11. Functionmypower(ByValnumAsCurrency,ByValpowerAsLong)AsString'UDFtocalculatepowersofa10-digitnumber
  12. Dimb(),temp
  13. ReDimb(1To2*power)
  14. ReDims(1To2*power)
  15. 'Thelasttwoelementoftheresult,i.e.numitself
  16. b(2*power-1)=Val(Left(num,5))'init
  17. b(2*power)=Val(Right(num,5))'init
  18. Fori=2Topower
  19. temp=0
  20. Forj=2*powerTo1Step-1
  21. temp=b(j)*num+temp
  22. b(j)=Format(Val(Right(temp,5)),"00000")'100000adic
  23. temp=Int(temp/10^5)
  24. Next
  25. Next
  26. mypower=Join(b,"")'Thefinalresult
  27. EndFunction
  28. PrivateSubCommand1_Click()
  29. DimindexAsLong,jAsCurrency,sAsString
  30. Index = CLng(InputBox("Please enter an integer within 1-30", "Info", 2))
  31. Forj=3*Int(10^(10-1/index)/3)To 9999999999# Step3'ntimes0-9mustbedivisibleby3
  32. DoEvents
  33. s=mypower(j,index)'theresult
  34. Ifbefit(s,index)Then'scontains0-9eachforindextimes
  35. Open"c:\"& index &".txt"ForBinaryAs#1'Outputtoatextfile
  36. Put#1,,j&"^"&index&"="&s'Printtheresult
  37. Close#1
  38. EndIf
  39. End
  40. Next
  41. EndSub

Since it have to enum a mount of 10-digit numbers,I compiled it to an windows applicationran and run the program in 4 PCs with different index , I've got the first 18 numbers till now(Numbers of otherindex: are still running):

1023456789^1=1023456789
3164252736^2=10012495377283485696
4642110594^3=100033726751278963952981464584
5623720662^4=1000218682348975505736229176987914443536
6312942339^5=10026725211153654390647841773200637448888932595699
6813614229^6=100061094057342858338669213648989907272573726634945455718121
7197035958^7=1000174338562286975299093890542029857149684613078516674136378324154752
7513755246^8=10159126159182043894548182772732556416094700698382830384251729403677604659937536
7747685775^9=100588420220833267470480529930325768811210496267095564714166268334749167599758148193359375
7961085846^10=1022640693192423918177472081495528045704001257405737138779536432199258656683133613589649088809624576
8120306331^11=10122704098280838738172663899155037525077864931542099359740473382958509846605210754479164591281362667243664131
8275283289^12=103132237398088685094148078064865552159324856064887274905478374353291741047910665437929791704128950573536662022369961121
8393900487^13=1026903443699705827527536011508380184886293234662850067608075167429132223154193162185649469905953603798419838589572701415774734247
8626922994^14=12646865508335605494843998794325485046341519468022708717028070547609519671202542318242559727117330589393633676024803151817278793689169412096
8594070624^15=103034762496243931091455752211526072992924547837934076638161515185979607268158486084352819994377954771846242628607531128031703303609805578845368090624
8691229761^16=1059984945135973085116625441940958734567890938937942910046410302827750560860737374626331724228885721853160790705924439371252226476405367618058329962361885148161
8800389678^17=11390226244546010693396746234792908564082582116481391247700038553190598561445998201373250115023954747487287071642058604917672993155873874536685736231662530396074892197888
8807854905^18=101780066705166236878346559130256930813111042299349121630146805870467163387920998553309748134869974589535455566056948852225484079291126292377577073478873342409711802829742431640625

Fortunately,I got a bigger number ,it appears when index=26:

9160395852^26=10227518575824412357774543428738315554963808756628545271950823008826278208489241129245927140719397161241846684623365292876389607982052697908581050074069519609796563228194931373316940301945115333795271107340007386839663447290510415078963123506544174796388696064

Since (10n)!*(10^10-10^(10-1/n))/((n!)^10 * 10^((10*n)-10^(10*n-1)) =0.31691419

That means it should exists 0.3169 numbers whose 26th power contains all digit for 26 times.But it exists!!! It's realy a wonder!!!

你可能感兴趣的:(windows,J#)