#include <stdio.h>
// グローバル変数cを定義し、カウント用の変数として使う
int c = 0;
// rec関数の定義
int rec(int n) {
// 最初の3項を返す
if (n == 0) {
return 3;
} else if (n == 1) {
return 0;
} else if (n == 2) {
return 2;
} else {
// n >= 3 の場合は再帰的に計算
return rec(n - 2) + rec(n - 3);
}
}
int main(void) {
int n = 50;
// 0からnまでの各項を列挙
for (int i = 1; i <= n; i++) { // n=0は無視するのでi=1から開始
int value = rec(i);
if (value % i == 0) { // a(n)がnで割り切れる場合
c++; // 割り切れる場合、カウントをインクリメント
}
}
// カウント結果を表示
printf("Total count of n where a(n) is divisible by n: %d\n", c
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyDjgrDjg63jg7zjg5Djg6vlpInmlbBj44KS5a6a576p44GX44CB44Kr44Km44Oz44OI55So44Gu5aSJ5pWw44Go44GX44Gm5L2/44GGCmludCBjID0gMDsKCi8vIHJlY+mWouaVsOOBruWumue+qQppbnQgcmVjKGludCBuKSB7CiAgICAvLyDmnIDliJ3jga4z6aCF44KS6L+U44GZCiAgICBpZiAobiA9PSAwKSB7CiAgICAgICAgcmV0dXJuIDM7CiAgICB9IGVsc2UgaWYgKG4gPT0gMSkgewogICAgICAgIHJldHVybiAwOwogICAgfSBlbHNlIGlmIChuID09IDIpIHsKICAgICAgICByZXR1cm4gMjsKICAgIH0gZWxzZSB7CiAgICAgICAgLy8gbiA+PSAzIOOBruWgtOWQiOOBr+WGjeW4sOeahOOBq+ioiOeulwogICAgICAgIHJldHVybiByZWMobiAtIDIpICsgcmVjKG4gLSAzKTsKICAgIH0KfQoKaW50IG1haW4odm9pZCkgewogICAgaW50IG4gPSA1MDsgCiAgICAvLyAw44GL44KJbuOBvuOBp+OBruWQhOmgheOCkuWIl+aMmQogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSB7IC8vIG49MOOBr+eEoeimluOBmeOCi+OBruOBp2k9MeOBi+OCiemWi+WniwogICAgICAgIGludCB2YWx1ZSA9IHJlYyhpKTsKICAgICAgICBpZiAodmFsdWUgJSBpID09IDApIHsgLy8gYShuKeOBjG7jgaflibLjgorliIfjgozjgovloLTlkIgKICAgICAgICAgICAgYysrOyAvLyDlibLjgorliIfjgozjgovloLTlkIjjgIHjgqvjgqbjg7Pjg4jjgpLjgqTjg7Pjgq/jg6rjg6Hjg7Pjg4gKICAgICAgICB9CiAgICB9CiAgICAKICAgIC8vIOOCq+OCpuODs+ODiOe1kOaenOOCkuihqOekugogICAgcHJpbnRmKCJUb3RhbCBjb3VudCBvZiBuIHdoZXJlIGEobikgaXMgZGl2aXNpYmxlIGJ5IG46ICVkXG4iLCBjKTsKICAgIAogICAgcmV0dXJuIDA7Cn0K