#include <stdio.h>
//練習問題E
int tri(int n) {
if(n==0){
return 0;
}
else if(n==1){
return 0;
}
else if(n==2){
return 1;
}
else{
return tri(n-1) +tri(n-2) +tri(n-3);
}
}
int main(void) {
int n = 7;
printf("数列Tnについて, n=%dのときの値は%d\n", n
, tri
(n
)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Ci8v57e057+S5ZWP6aGMRQppbnQgdHJpKGludCBuKSB7CglpZihuPT0wKXsKCQlyZXR1cm4gMDsKCX0KCWVsc2UgaWYobj09MSl7CgkJcmV0dXJuIDA7Cgl9CgllbHNlIGlmKG49PTIpewoJCXJldHVybiAxOwoJfQoJZWxzZXsKCQlyZXR1cm4gdHJpKG4tMSkgK3RyaShuLTIpICt0cmkobi0zKTsKCX0KfQoKCgppbnQgbWFpbih2b2lkKSB7CglpbnQgbiA9IDc7CiAgICBwcmludGYoIuaVsOWIl1Ru44Gr44Gk44GE44GmLCBuPSVk44Gu44Go44GN44Gu5YCk44GvJWRcbiIsIG4sIHRyaShuKSk7CglyZXR1cm4gMDsKfQo=