#include <stdio.h>

#define SIZE 8
#define BASE 10000000

// 関数プロトタイプ宣言（固定）
void power3(unsigned long result[], int exponent);
void print_result(unsigned long result[]);

int main(void) { 
    unsigned long result[SIZE] = {0}; // 結果の初期化

    for (int i = 1; i <= 99; i++) {
        power3(result, i);
        printf("3^%d = ", i);
        print_result(result);
    }

    return 0; 
}

void power3(unsigned long result[], int exponent) {
    // 結果をゼロにリセット
    for (int j = 0; j < SIZE; j++) {
        result[j] = 0; 
    }
    result[0] = 1; // 3の0乗は1

    for (int i = 1; i <= exponent; i++) { 
        unsigned long carry = 0;
        
        for (int j = 0; j < SIZE; j++) {
            unsigned long tmp = result[j] * 3 + carry;
            result[j] = tmp % BASE;
            carry = tmp / BASE;
        }

        // 残った繰り上がりを処理
        if (carry > 0) {
            for (int j = SIZE - 1; j > 0; j--) {
                result[j] = result[j - 1];
            }
            result[0] = carry;
        }
    }
}

void print_result(unsigned long result[]) {
    int started = 0; // 先頭のゼロをスキップするためのフラグ
    for (int i = SIZE - 1; i >= 0; i--) {
        if (result[i] != 0) {
            started = 1; // 最初の非ゼロ桁を見つけた
        }
        if (started) {
            if (i < SIZE - 1) { // 先頭以外の桁には0を追加
                printf("%07lu", result[i]);
            } else {
                printf("%lu", result[i]); // 先頭の桁はそのまま表示
            }
        }
    }
    if (!started) { // すべての桁がゼロの場合
        printf("0");
    }
    printf("\n"); // 改行
}
