fork download
  1. #include <stdio.h>
  2. void power3(unsigned long result[]);
  3. void print_result(unsigned long result[]);
  4.  
  5. int main(void) {
  6. unsigned long result[8]={0};
  7. result[0]=1;
  8. for(int i=0;i<=99;i++){
  9. power3(result);
  10. printf("n= %d:",i);
  11. print_result(result);
  12. }
  13. return 0;
  14. }
  15. void power3(unsigned long result[]){
  16. unsigned long carry=0;
  17. for(int i=0;i<8;i++){
  18. unsigned long temp=result[i]*3+carry;
  19. result[i]=temp%10000000;
  20. carry=temp/10000000;
  21. }
  22. }
  23. void print_result(unsigned long result[]){
  24. int first=0;
  25. for(int i=7;i>=0;i--){
  26. if(result[i]!=0){
  27. printf("%lu",result[i]);
  28. first=1;
  29. }else if(first){
  30. printf("%07lu",result[i]);
  31. }
  32.  
  33. }
  34. printf("\n");
  35. }
  36.  
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
n= 0:3
n= 1:9
n= 2:27
n= 3:81
n= 4:243
n= 5:729
n= 6:2187
n= 7:6561
n= 8:19683
n= 9:59049
n= 10:177147
n= 11:531441
n= 12:1594323
n= 13:4782969
n= 14:14348907
n= 15:43046721
n= 16:129140163
n= 17:387420489
n= 18:1162261467
n= 19:3486784401
n= 20:1046353203
n= 21:31381059609
n= 22:94143178827
n= 23:282429536481
n= 24:847288609443
n= 25:2541865828329
n= 26:7625597484987
n= 27:22876792454961
n= 28:68630377364883
n= 29:25891132094649
n= 30:617673396283947
n= 31:1853020188851841
n= 32:5559060566555523
n= 33:16677181699666569
n= 34:50031545098999707
n= 35:150094635296999121
n= 36:45028390589997363
n= 37:1350851717672992089
n= 38:4052555153018976267
n= 39:12157665459056928801
n= 40:3647299637717786403
n= 41:109418989131512359209
n= 42:328256967394537077627
n= 43:98477092183611232881
n= 44:295431276550833698643
n= 45:8862938119652501095929
n= 46:26588814358957503287787
n= 47:79766443076872509863361
n= 48:239299329230617529590083
n= 49:717897987691852588770249
n= 50:2153693963075557766310747
n= 51:646181889226673298932241
n= 52:19383245667680019896796723
n= 53:5814973700304005969390169
n= 54:174449211009120179071170507
n= 55:523347633027360537213511521
n= 56:157004289908208161164534563
n= 57:4710128697246244834921603689
n= 58:1413038691738734504764811067
n= 59:4239115827521623514294433201
n= 60:127173474825648610542883299603
n= 61:381520424476945831628649898809
n= 62:1144561273430837494885949696427
n= 63:3433683820292512484657849089281
n= 64:10301051460877537453973547267843
n= 65:30903154382632612361920641803529
n= 66:92709463147897837085761925410587
n= 67:278128389443693511257285776231761
n= 68:83438516833180533771857328695283
n= 69:2503155504993241601315571986085849
n= 70:7509466514979724803946715958257547
n= 71:22528399544939174411840147874772641
n= 72:67585198634817523235520443624317923
n= 73:22755595904452569706561330872953769
n= 74:68266787713357709119683992618861307
n= 75:1824800363140073127359051977856583921
n= 76:5474401089420219382077155933569751763
n= 77:16423203268260658146231467800709255289
n= 78:4926960980478197443869443402127765867
n= 79:14788829414345923316083210206383297601
n= 80:443426488243037769948249630619149892803
n= 81:1330279464729113309844748891857449678409
n= 82:3990838394187339929534246675572349035227
n= 83:11972515182562019788602740026717047105681
n= 84:35917545547686059365808220080151141317043
n= 85:107752636643058178097424660240453423951129
n= 86:32325799929174534292273980721360271853387
n= 87:969773729787523602876821942164080815560161
n= 88:290932118936257808630465826492242446680483
n= 89:87279635680877124258913974794767273441449
n= 90:261838907426313727767419243843018202124347
n= 91:7855167211278941183302257731529054606373041
n= 92:235655016338368235499067731945871638181119123
n= 93:706965049015104706497203195837614914543357369
n= 94:21208951470453141194916095875128447436372107
n= 95:636268544113594235847482876253853423089216321
n= 96:1908856323478270754244862876156269267648963
n= 97:5726416897022348122627345886284688078011946889
n= 98:171792506910670443678820376588540424234035840667
n= 99:515377520732011331036461129765621272702107522001