fork download
  1. #include <stdio.h>
  2.  
  3. void power3(unsigned long result[ ]);
  4. void print_result(unsigned long result[ ]);
  5. int count;
  6.  
  7. int main(void) {
  8. unsigned long result[6] = {0, 0, 0, 0, 0, 0};
  9. result[0] = 1;
  10. for(count = 0; count < 99; count++){
  11. power3(result);
  12. print_result(result);
  13. }
  14. return 0;
  15. }
  16.  
  17. void power3(unsigned long result[ ]){
  18. for(int i = 0; i < 6; i++){
  19. result[i] *= 3;
  20. if((result[i] / 100000000) >= 1){
  21. result[i+1] += result[i] / 100000000;
  22. result[i] -= (result[i] / 100000000) * 100000000;
  23. }
  24. }
  25. }
  26.  
  27. void print_result(unsigned long result[ ]){
  28. int digit, num;
  29. printf("n = %d : ", count+1);
  30. for(int i = 5; i >= 0; i--){
  31. num = result[i];
  32. while(num != 0){
  33. num = num / 10;
  34. digit++;
  35. }
  36. for(int i = 0; i < (8-digit); i++){
  37. printf("");
  38. }
  39. if(result[i] != 0)
  40. printf("%lu", result[i]);
  41. printf("\n");
  42. }
  43. printf("\n");
  44. }
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
n = 1 : 




3

n = 2 : 




9

n = 3 : 




27

n = 4 : 




81

n = 5 : 




243

n = 6 : 




729

n = 7 : 




2187

n = 8 : 




6561

n = 9 : 




19683

n = 10 : 




59049

n = 11 : 




177147

n = 12 : 




531441

n = 13 : 




1594323

n = 14 : 




4782969

n = 15 : 




14348907

n = 16 : 




43046721

n = 17 : 



3
29140163

n = 18 : 



9
87420489

n = 19 : 



33
62261467

n = 20 : 



102
86784401

n = 21 : 



312
60353203

n = 22 : 



939
81059609

n = 23 : 



2823
43178827

n = 24 : 



8472
29536481

n = 25 : 



25416
88609443

n = 26 : 



76254
65828329

n = 27 : 



228765
97484987

n = 28 : 



686301
92454961

n = 29 : 



2058909
77364883

n = 30 : 



6176733
32094649

n = 31 : 



18530199
96283947

n = 32 : 



55590603
88851841

n = 33 : 


3
66771815
66555523

n = 34 : 


15
315448
99666569

n = 35 : 


45
946350
98999707

n = 36 : 


135
2839056
96999121

n = 37 : 


405
8517174
90997363

n = 38 : 


1215
25551528
72992089

n = 39 : 


3645
76654590
18976267

n = 40 : 


10941
29963770
56928801

n = 41 : 


32823
89891313
70786403

n = 42 : 


98475
69673945
12359209

n = 43 : 


295431
9021835
37077627

n = 44 : 


886293
27065508
11232881

n = 45 : 


2658879
81196524
33698643

n = 46 : 


7976643
43589575
1095929

n = 47 : 


23929932
30768725
3287787

n = 48 : 


71789796
92306175
9863361

n = 49 : 

6
15369394
76918525
29590083

n = 50 : 

18
46108188
30755575
88770249

n = 51 : 

57
38324564
92266731
66310747

n = 52 : 

174
14973698
76800196
98932241

n = 53 : 

522
44921100
30400594
96796723

n = 54 : 

1569
34763300
91201788
90390169

n = 55 : 

4710
4289906
73605370
71170507

n = 56 : 

14130
12869724
20816116
13511521

n = 57 : 

42390
38609172
62448348
40534563

n = 58 : 

127173
15827519
87345047
21603689

n = 59 : 

381519
47482563
62035141
64811067

n = 60 : 

1144560
42447692
86105426
94433201

n = 61 : 

3433683
27343082
58316284
83299603

n = 62 : 

10301049
82029249
74948858
49898809

n = 63 : 

30903153
46087753
24846577
49696427

n = 64 : 

92709462
38263259
74539734
49089281

n = 65 : 
6
78128389
14789783
23619205
47267843

n = 66 : 
24
34385167
44369349
70857618
41803529

n = 67 : 
75
3155504
33108053
12572857
25410587

n = 68 : 
225
9466512
99324159
37718571
76231761

n = 69 : 
675
28399542
97972480
13155719
28695283

n = 70 : 
2025
85198632
93917440
39467157
86085849

n = 71 : 
6081
55595902
81752323
18401477
58257547

n = 72 : 
18246
66787712
45256969
55204434
74772641

n = 73 : 
54744
363139
35770910
65613308
24317923

n = 74 : 
164232
1089420
7312733
96839924
72953769

n = 75 : 
492696
3268260
21938205
90519778
18861307

n = 76 : 
1478088
9804780
65814621
71559334
56583921

n = 77 : 
4434264
29414343
97443869
14678005
69751763

n = 78 : 
13302792
88243035
92331607
44034021
9255289

n = 79 : 
39908382
64729111
76994824
32102063
27765867

n = 80 : 3
19725149
94187339
30984472
96306189
83297601

n = 81 : 9
59175453
82562017
92953422
88918573
49892803

n = 82 : 30
77526365
47686057
78860272
66755722
49678409

n = 83 : 96
32579098
43058177
36580822
267169
49035227

n = 84 : 288
97737297
29174534
9742466
801510
47105681

n = 85 : 870
93211891
87523602
29227398
2404533
41317043

n = 86 : 2616
79635679
62570806
87682194
7213602
23951129

n = 87 : 7854
38907040
87712424
63046582
21640806
71853387

n = 88 : 23565
16721126
63137275
89139746
64922424
15560161

n = 89 : 70695
50163381
89411831
67419241
94767272
46680483

n = 90 : 212088
50490149
68235499
2257729
84301819
40041449

n = 91 : 636267
51470453
4706497
6773193
52905460
20124347

n = 92 : 1908804
54411359
14119491
20319582
58716380
60373041

n = 93 : 5726415
63234077
42358473
60958749
76149143
81119123

n = 94 : 17179248
89702234
27075422
82876253
28447435
43357369

n = 95 : 51537750
69106702
81226272
48628759
85342308
30072107

n = 96 : 54613256
7320112
43678819
45886283
56026924
90216321

n = 97 : 63839768
21960339
31036460
37658852
68080778
70648963

n = 98 : 91519304
65881017
93109383
12976562
4242340
11946889

n = 99 : 74557915
97643057
79328149
38929686
12727020
35840667