#include <stdio.h>
int main() {
int N;
// 使用無窮迴圈來持續讀取輸入,直到遇到終止條件
while (1) {
// 讀取 N 的值
// 若 N 等於 0,則結束迴圈
if (N == 0)
break;
// 初始化 G 的值,G 用來存放所有 GCD 值的總和
long long G = 0;
int i, j, a, b, temp;
// 外層迴圈,從 i=1 到 i=N-1,依序遍歷每一個 i
for (i = 1; i < N; i++) {
// 內層迴圈,從 j=i+1 到 j=N,遍歷每一個 j,且 j > i
for (j = i + 1; j <= N; j++) {
// 將 i 和 j 的值賦予變數 a 和 b,準備計算 GCD
a = i;
b = j;
// 使用輾轉相除法 (歐幾里得算法) 計算 GCD
while (b != 0) {
// 儲存 b 的值,以便下一步操作
temp = b;
// 計算 a 除以 b 的餘數,並賦值給 b
b = a % b;
// 將 b 的值賦值給 a,繼續下一次循環
a = temp;
}
// 最後 a 的值即為 GCD(i, j),將其加到 G 中
G = G + a;
}
}
// 輸出 G 的值,代表對應 N 的總和 GCD(i, j)
}
return 0; // 程式結束
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBOOwoKICAgIC8vIOS9v+eUqOeEoeeqrui/tOWciOS+huaMgee6jOiugOWPlui8uOWFpe+8jOebtOWIsOmBh+WIsOe1guatouaineS7tgogICAgd2hpbGUgKDEpIHsKICAgICAgICAvLyDoroDlj5YgTiDnmoTlgLwKICAgICAgICBzY2FuZigiJWQiLCAmTik7CgogICAgICAgIC8vIOiLpSBOIOetieaWvCAw77yM5YmH57WQ5p2f6L+05ZyICiAgICAgICAgaWYgKE4gPT0gMCkKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIC8vIOWIneWni+WMliBHIOeahOWAvO+8jEcg55So5L6G5a2Y5pS+5omA5pyJIEdDRCDlgLznmoTnuL3lkowKICAgICAgICBsb25nIGxvbmcgRyA9IDA7CgogICAgICAgIGludCBpLCBqLCBhLCBiLCB0ZW1wOwoKICAgICAgICAvLyDlpJblsaTov7TlnIjvvIzlvp4gaT0xIOWIsCBpPU4tMe+8jOS+neW6j+mBjeatt+avj+S4gOWAiyBpCiAgICAgICAgZm9yIChpID0gMTsgaSA8IE47IGkrKykgewogICAgICAgICAgICAvLyDlhaflsaTov7TlnIjvvIzlvp4gaj1pKzEg5YiwIGo9Tu+8jOmBjeatt+avj+S4gOWAiyBq77yM5LiUIGogPiBpCiAgICAgICAgICAgIGZvciAoaiA9IGkgKyAxOyBqIDw9IE47IGorKykgewogICAgICAgICAgICAgICAgLy8g5bCHIGkg5ZKMIGog55qE5YC86LOm5LqI6K6K5pW4IGEg5ZKMIGLvvIzmupblgpnoqIjnrpcgR0NECiAgICAgICAgICAgICAgICBhID0gaTsKICAgICAgICAgICAgICAgIGIgPSBqOwoKICAgICAgICAgICAgICAgIC8vIOS9v+eUqOi8vui9ieebuOmZpOazlSAo5q2Q5bm+6YeM5b6X566X5rOVKSDoqIjnrpcgR0NECiAgICAgICAgICAgICAgICB3aGlsZSAoYiAhPSAwKSB7CiAgICAgICAgICAgICAgICAgICAgLy8g5YSy5a2YIGIg55qE5YC877yM5Lul5L6/5LiL5LiA5q2l5pON5L2cCiAgICAgICAgICAgICAgICAgICAgdGVtcCA9IGI7CiAgICAgICAgICAgICAgICAgICAgLy8g6KiI566XIGEg6Zmk5LulIGIg55qE6aSY5pW477yM5Lim6LOm5YC857WmIGIKICAgICAgICAgICAgICAgICAgICBiID0gYSAlIGI7CiAgICAgICAgICAgICAgICAgICAgLy8g5bCHIGIg55qE5YC86LOm5YC857WmIGHvvIznubznuozkuIvkuIDmrKHlvqrnkrAKICAgICAgICAgICAgICAgICAgICBhID0gdGVtcDsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAvLyDmnIDlvowgYSDnmoTlgLzljbPngrogR0NEKGksIGop77yM5bCH5YW25Yqg5YiwIEcg5LitCiAgICAgICAgICAgICAgICBHID0gRyArIGE7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIOi8uOWHuiBHIOeahOWAvO+8jOS7o+ihqOWwjeaHiSBOIOeahOe4veWSjCBHQ0QoaSwgaikKICAgICAgICBwcmludGYoIiVsbGRcbiIsIEcpOwogICAgfQoKICAgIHJldHVybiAwOyAvLyDnqIvlvI/ntZDmnZ8KfQ==