fork(2) 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 = 5; i >= 0; 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. digit = 0;
  32. num = result[i];
  33. while(num != 0){
  34. num = num / 10;
  35. digit++;
  36. }
  37. for(int i = 0; i < (8-digit); i++){
  38. printf(" ");
  39. }
  40. if(result[i] != 0)
  41. printf("%lu", result[i]);
  42.  
  43. printf(" ");
  44. }
  45. printf("\n");
  46. }
Success #stdin #stdout 0s 5272KB
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 :                                            1 29140163 
n = 18 :                                            3 87420489 
n = 19 :                                           11 62261467 
n = 20 :                                           34 86784401 
n = 21 :                                          104 60353203 
n = 22 :                                          313 81059609 
n = 23 :                                          941 43178827 
n = 24 :                                         2824 29536481 
n = 25 :                                         8472 88609443 
n = 26 :                                        25418 65828329 
n = 27 :                                        76255 97484987 
n = 28 :                                       228767 92454961 
n = 29 :                                       686303 77364883 
n = 30 :                                      2058911 32094649 
n = 31 :                                      6176733 96283947 
n = 32 :                                     18530201 88851841 
n = 33 :                                     55590605 66555523 
n = 34 :                                   1 66771816 99666569 
n = 35 :                                   5   315450 98999707 
n = 36 :                                  15   946352 96999121 
n = 37 :                                  45  2839058 90997363 
n = 38 :                                 135  8517176 72992089 
n = 39 :                                 405 25551530 18976267 
n = 40 :                                1215 76654590 56928801 
n = 41 :                                3647 29963771 70786403 
n = 42 :                               10941 89891315 12359209 
n = 43 :                               32825 69673945 37077627 
n = 44 :                               98477  9021836 11232881 
n = 45 :                              295431 27065508 33698643 
n = 46 :                              886293 81196525  1095929 
n = 47 :                             2658881 43589575  3287787 
n = 48 :                             7976644 30768725  9863361 
n = 49 :                            23929932 92306175 29590083 
n = 50 :                            71789798 76918525 88770249 
n = 51 :                          2 15369396 30755577 66310747 
n = 52 :                          6 46108188 92266732 98932241 
n = 53 :                         19 38324566 76800198 96796723 
n = 54 :                         58 14973700 30400596 90390169 
n = 55 :                        174 44921100 91201790 71170507 
n = 56 :                        523 34763302 73605372 13511521 
n = 57 :                       1570  4289908 20816116 40534563 
n = 58 :                       4710 12869724 62448349 21603689 
n = 59 :                      14130 38609173 87345047 64811067 
n = 60 :                      42391 15827521 62035142 94433201 
n = 61 :                     127173 47482564 86105428 83299603 
n = 62 :                     381520 42447694 58316286 49898809 
n = 63 :                    1144561 27343083 74948859 49696427 
n = 64 :                    3433683 82029251 24846578 49089281 
n = 65 :                   10301051 46087753 74539735 47267843 
n = 66 :                   30903154 38263261 23619206 41803529 
n = 67 :                   92709463 14789783 70857619 25410587 
n = 68 :                 2 78128389 44369351 12572857 76231761 
n = 69 :                 8 34385168 33108053 37718573 28695283 
n = 70 :                25  3155504 99324160 13155719 86085849 
n = 71 :                75  9466514 97972480 39467159 58257547 
n = 72 :               225 28399544 93917441 18401478 74772641 
n = 73 :               675 85198634 81752323 55204436 24317923 
n = 74 :              2027 55595904 45256970 65613308 72953769 
n = 75 :              6082 66787713 35770911 96839926 18861307 
n = 76 :             18248   363140  7312735 90519778 56583921 
n = 77 :             54744  1089420 21938207 71559335 69751763 
n = 78 :            164232  3268260 65814623 14678007  9255289 
n = 79 :            492696  9804781 97443869 44034021 27765867 
n = 80 :           1478088 29414345 92331608 32102063 83297601 
n = 81 :           4434264 88243037 76994824 96306191 49892803 
n = 82 :          13302794 64729113 30984474 88918574 49678409 
n = 83 :          39908383 94187339 92953424 66755723 49035227 
n = 84 :        1 19725151 82562019 78860274   267170 47105681 
n = 85 :        3 59175455 47686059 36580822   801511 41317043 
n = 86 :       10 77526366 43058178  9742466  2404534 23951129 
n = 87 :       32 32579099 29174534 29227398  7213602 71853387 
n = 88 :       96 97737297 87523602 87682194 21640808 15560161 
n = 89 :      290 93211893 62570808 63046582 64922424 46680483 
n = 90 :      872 79635680 87712425 89139747 94767273 40041449 
n = 91 :     2618 38907042 63137277 67419243 84301820 20124347 
n = 92 :     7855 16721127 89411833  2257731 52905460 60373041 
n = 93 :    23565 50163383 68235499  6773194 58716381 81119123 
n = 94 :    70696 50490151  4706497 20319583 76149145 43357369 
n = 95 :   212089 51470453 14119491 60958751 28447436 30072107 
n = 96 :   636268 54411359 42358474 82876253 85342308 90216321 
n = 97 :  1908805 63234078 27075424 48628761 56026926 70648963 
n = 98 :  5726416 89702234 81226273 45886284 68080780 11946889 
n = 99 : 17179250 69106704 43678820 37658854  4242340 35840667