#include <stdio.h>
//a{n} = 2a{n-1} + a{n-2}, a{1}=2, a{2}=3(再帰なし版)
int rec(int n){
if(n==0){
return 3;
}
else if(n==1){
return 0;
}
else if(n==2){
return 2;
}
else{
return rec(n-2)+rec(n-3);
}
}
int main(void) {
int n=50,i;
for(i=1; i<=n; i++){
if(rec(i)%i==0){
printf("数列a%dの値は%d\n", i
, rec
(i
)); }
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Ci8vYXtufSA9IDJhe24tMX0gKyBhe24tMn0sIGF7MX09MiwgYXsyfT0zKOWGjeW4sOOBquOBl+eJiCkKCmludCByZWMoaW50IG4pewoJaWYobj09MCl7CgkJcmV0dXJuIDM7Cgl9CgllbHNlIGlmKG49PTEpewoJCXJldHVybiAwOwoJfQoJZWxzZSBpZihuPT0yKXsKCQlyZXR1cm4gMjsKCX0KCWVsc2V7CgkJcmV0dXJuIHJlYyhuLTIpK3JlYyhuLTMpOwoJfQp9CgppbnQgbWFpbih2b2lkKSB7CglpbnQgbj01MCxpOwoJZm9yKGk9MTsgaTw9bjsgaSsrKXsKCQlpZihyZWMoaSklaT09MCl7CiAgICAJCXByaW50Zigi5pWw5YiXYSVk44Gu5YCk44GvJWRcbiIsIGksIHJlYyhpKSk7CgkJfQoJfQoJcmV0dXJuIDA7Cn0KCg==