fork download
  1. #include <stdio.h>
  2.  
  3. void power3(unsigned long result[]);
  4. void printf_result(unsigned long result[]);
  5.  
  6. int main(void) {
  7. unsigned long result[8] = {0};
  8. result[0] = 1;
  9. for ( int i = 1; i < 100; i ++ )
  10. {
  11. power3 (result);
  12. printf ("n=%2d: ", i);
  13. printf_result (result);
  14. }
  15. return 0;
  16. }
  17.  
  18. void power3(unsigned long result[])
  19. {
  20. unsigned long x = 0;
  21.  
  22. for ( int i = 0; i < 7; i++ )
  23. {
  24. unsigned long temp = result[i]*3 + x;
  25. result[i] = temp % 10000000;
  26. x = temp / 10000000;
  27. }
  28. }
  29.  
  30. void printf_result(unsigned long result[])
  31. {
  32. for ( int i = 6; i >= 0; i-- )
  33. {
  34. if ( result[i] == 0 )
  35. {
  36. printf(" ");
  37. }
  38. else
  39. {
  40. printf (" %7lu", result[i]);
  41. }
  42.  
  43. }
  44.  
  45. printf("\n");
  46. }
Success #stdin #stdout 0.01s 5280KB
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:                                                1 4348907
n=16:                                                4 3046721
n=17:                                               12 9140163
n=18:                                               38 7420489
n=19:                                              116 2261467
n=20:                                              348 6784401
n=21:                                             1046  353203
n=22:                                             3138 1059609
n=23:                                             9414 3178827
n=24:                                            28242 9536481
n=25:                                            84728 8609443
n=26:                                           254186 5828329
n=27:                                           762559 7484987
n=28:                                          2287679 2454961
n=29:                                          6863037 7364883
n=30:                                        2  589113 2094649
n=31:                                        6 1767339 6283947
n=32:                                       18 5302018 8851841
n=33:                                       55 5906056 6555523
n=34:                                      166 7718169 9666569
n=35:                                      500 3154509 8999707
n=36:                                     1500 9463529 6999121
n=37:                                     4502 8390589  997363
n=38:                                    13508 5171767 2992089
n=39:                                    40525 5515301 8976267
n=40:                                   121576 6545905 6928801
n=41:                                   364729 9637717  786403
n=42:                                  1094189 8913151 2359209
n=43:                                  3282569 6739453 7077627
n=44:                                  9847709  218361 1232881
n=45:                                2 9543127  655083 3698643
n=46:                                8 8629381 1965250 1095929
n=47:                               26 5888143 5895750 3287787
n=48:                               79 7664430 7687250 9863361
n=49:                              239 2993292 3061752 9590083
n=50:                              717 8979876 9185258 8770249
n=51:                             2153 6939630 7555776 6310747
n=52:                             6461  818892 2667329 8932241
n=53:                            19383 2456676 8001989 6796723
n=54:                            58149 7370030 4005969  390169
n=55:                           174449 2110091 2017907 1170507
n=56:                           523347 6330273 6053721 3511521
n=57:                          1570042 8990820 8161164  534563
n=58:                          4710128 6972462 4483492 1603689
n=59:                        1 4130386  917387 3450476 4811067
n=60:                        4 2391158 2752162  351429 4433201
n=61:                       12 7173474 8256486 1054288 3299603
n=62:                       38 1520424 4769458 3162864 9898809
n=63:                      114 4561273 4308374 9488594 9696427
n=64:                      343 3683820 2925124 8465784 9089281
n=65:                     1030 1051460 8775374 5397354 7267843
n=66:                     3090 3154382 6326123 6192064 1803529
n=67:                     9270 9463147 8978370 8576192 5410587
n=68:                    27812 8389443 6935112 5728577 6231761
n=69:                    83438 5168331  805337 7185732 8695283
n=70:                   250315 5504993 2416013 1557198 6085849
n=71:                   750946 6514979 7248039 4671595 8257547
n=72:                  2252839 9544939 1744118 4014787 4772641
n=73:                  6758519 8634817 5232355 2044362 4317923
n=74:                2  275559 5904452 5697065 6133087 2953769
n=75:                6  826678 7713357 7091196 8399261 8861307
n=76:               18 2480036 3140073 1273590 5197785 6583921
n=77:               54 7440108 9420219 3820771 5593356 9751763
n=78:              164 2320326 8260658 1462314 6780070 9255289
n=79:              492 6960980 4781974 4386944  340212 7765867
n=80:             1478  882941 4345923 3160832 1020638 3297601
n=81:             4434 2648824 3037769 9482496 3061914 9892803
n=82:            13302 7946472 9113309 8447488 9185744 9678409
n=83:            39908 3839418 7339929 5342466 7557234 9035227
n=84:           119725 1518256 2019788 6027400 2671704 7105681
n=85:           359175 4554768 6059365 8082200 8015114 1317043
n=86:          1077526 3664305 8178097 4246602 4045342 3951129
n=87:          3232579  992917 4534292 2739807 2136027 1853387
n=88:          9697737 2978752 3602876 8219421 6408081 5560161
n=89:        2 9093211 8936257  808630 4658264 9224244 6680483
n=90:        8 7279635 6808771 2425891 3974794 7672734   41449
n=91:       26 1838907  426313 7277674 1924384 3018202  124347
n=92:       78 5516721 1278941 1833022 5773152 9054606  373041
n=93:      235 6550163 3836823 5499067 7319458 7163818 1119123
n=94:      706 9650490 1510470 6497203 1958376 1491454 3357369
n=95:     2120 8951470 4531411 9491609 5875128 4474363   72107
n=96:     6362 6854411 3594235 8474828 7625385 3423089  216321
n=97:    19088  563234  782707 5424486 2876156  269267  648963
n=98:    57264 1689702 2348122 6273458 8628468  807801 1946889
n=99:   171792 5069106 7044367 8820376 5885404 2423403 5840667