fork(1) download
  1. #include <stdio.h>
  2.  
  3. void power3(unsigned long result[]) {
  4. unsigned long temp[8] = {0}; // Initialize temp array
  5. unsigned long carry = 0; // Variable to hold carry over
  6.  
  7. for (int j = 0; j < 8; j++) {
  8. temp[j] = result[j] * 3 + carry; // Multiply and add carry
  9. carry = temp[j] / 10000000; // Calculate new carry
  10.  
  11. if (j + 1 < 8) { // Ensure we don't access out of bounds
  12. result[j + 1] += carry; // Add carry to the next position
  13. }
  14.  
  15. result[j] = temp[j] % 10000000; // Store the result
  16. }
  17. }
  18.  
  19. void print_result(unsigned long result[]) {
  20. // Print results; note that `i` and `j` should be defined correctly
  21. for (int j = 0; j < 8; j++) {
  22. printf("%lu ", result[j]);
  23. }
  24. printf("\n");
  25. }
  26.  
  27. int main(void) {
  28. unsigned long result[8] = {1}; // Initialize the result array with 1 at position 0
  29.  
  30. for (int i = 0; i < 100; i++) {
  31. power3(result);
  32. print_result(result);
  33. }
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
3 0 0 0 0 0 0 0 
9 0 0 0 0 0 0 0 
27 0 0 0 0 0 0 0 
81 0 0 0 0 0 0 0 
243 0 0 0 0 0 0 0 
729 0 0 0 0 0 0 0 
2187 0 0 0 0 0 0 0 
6561 0 0 0 0 0 0 0 
19683 0 0 0 0 0 0 0 
59049 0 0 0 0 0 0 0 
177147 0 0 0 0 0 0 0 
531441 0 0 0 0 0 0 0 
1594323 0 0 0 0 0 0 0 
4782969 0 0 0 0 0 0 0 
4348907 4 0 0 0 0 0 0 
3046721 16 0 0 0 0 0 0 
9140163 48 0 0 0 0 0 0 
7420489 152 0 0 0 0 0 0 
2261467 464 0 0 0 0 0 0 
6784401 1392 0 0 0 0 0 0 
353203 4184 0 0 0 0 0 0 
1059609 12552 0 0 0 0 0 0 
3178827 37656 0 0 0 0 0 0 
9536481 112968 0 0 0 0 0 0 
8609443 338912 0 0 0 0 0 0 
5828329 1016744 0 0 0 0 0 0 
7484987 3050236 0 0 0 0 0 0 
2454961 9150716 0 0 0 0 0 0 
7364883 7452148 8 0 0 0 0 0 
2094649 2356452 32 0 0 0 0 0 
6283947 7069356 96 0 0 0 0 0 
8851841 1208072 296 0 0 0 0 0 
6555523 3624224 888 0 0 0 0 0 
9666569 872676 2668 0 0 0 0 0 
8999707 2618036 8004 0 0 0 0 0 
6999121 7854116 24012 0 0 0 0 0 
997363 3562356 72044 0 0 0 0 0 
2992089 687068 216136 0 0 0 0 0 
8976267 2061204 648408 0 0 0 0 0 
6928801 6183620 1945224 0 0 0 0 0 
786403 8550868 5835676 0 0 0 0 0 
2359209 5652604 7507036 4 0 0 0 0 
7077627 6957812 2521112 20 0 0 0 0 
1232881 873444 7563344 60 0 0 0 0 
3698643 2620332 2690032 188 0 0 0 0 
1095929 7861000 8070096 564 0 0 0 0 
3287787 3583000 4210296 1700 0 0 0 0 
9863361 749000 2630892 5104 0 0 0 0 
9590083 2247008 7892676 15312 0 0 0 0 
8770249 6741032 3678028 45944 0 0 0 0 
6310747 223104 1034092 137836 0 0 0 0 
8932241 669316 3102276 413508 0 0 0 0 
6796723 2007956 9306828 1240524 0 0 0 0 
390169 6023876 7920484 3721580 0 0 0 0 
1170507 8071628 3761456 1164748 4 0 0 0 
3511521 4214884 1284376 3494248 12 0 0 0 
534563 2644656 3853132 482744 40 0 0 0 
1603689 7933968 1559396 1448236 120 0 0 0 
4811067 3801904 4678196 4344708 360 0 0 0 
4433201 1405716 4034592 3034128 1084 0 0 0 
3299603 4217152 2103776 9102388 3252 0 0 0 
9898809 2651456 6311332 7307164 9764 0 0 0 
9696427 7954376 8933996 1921496 29300 0 0 0 
9089281 3863136 6801996 5764496 87900 0 0 0 
7267843 1589416 405992 7293496 263704 0 0 0 
1803529 4768256 1217976 1880488 791120 0 0 0 
5410587 4304768 3653932 5641464 2373360 0 0 0 
6231761 2914308 961800 6924396 7120084 0 0 0 
8695283 8742928 2885400 773188 1360260 8 0 0 
6085849 6228792 8656208 2319564 4080780 24 0 0 
8257547 8686380 5968628 6958700 2242340 76 0 0 
4772641 6059148 7905892 876104 6727028 228 0 0 
4317923 8177448 3717680 2628320 181084 692 0 0 
2953769 4532348 1153048 7884964 543252 2076 0 0 
8861307 3597044 3459148 3654892 1629764 6228 0 0 
6583921 791140 377448 964680 4889296 18684 0 0 
9751763 2373424 1132344 2894040 4667888 56056 0 0 
9255289 7120280 3397032 8682120 4003664 168172 0 0 
7765867 1360848 191104 6046364 2011000 504520 0 0 
3297601 4082552 573312 8139092 6033004 1513560 0 0 
9892803 2247656 1719940 4417276 8099020 4540684 0 0 
9678409 6742976 5159820 3251828 4297064 3622060 4 0 
9035227 228936 5479468 9755488 2891192 866184 16 0 
7105681 686816 6438404 9266468 8673584 2598552 48 0 
1317043 2060456 9315212 7799408 6020760 7795664 144 0 
3951129 6181368 7945636 3398232 8062288 3386996 440 0 
1853387 8544108 3836912 194704 4186868 160996 1324 0 
5560161 5632324 1510744 584116 2560604 482992 3972 0 
6680483 6896976 4532236 1752348 7681812 1448976 11916 0 
41449 690936 3596716 5257048 3045436 4346936 35748 0 
124347 2072808 790148 5771148 9136312 3040808 107248 0 
373041 6218424 2370444 7313444 7408940 9122432 321744 0 
1119123 8655272 7111336 1940332 2226828 7367304 965240 0 
3357369 5965816 1334016 5821004 6680484 2101912 2895728 0 
72107 7897452 4002052 7463012 41456 6305744 8687184 0 
216321 3692356 2006164 2389040 124376 8917232 6061556 8 
648963 1077068 6018496 7167120 373128 6751696 8184676 28 
1946889 3231204 8055488 1501364 1119392 255088 4554036 92 
5840667 9693612 4166464 4504100 3358176 765264 3662108 280 
7522001 9080840 2499400 3512304 74532 2295796 986324 844