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