#include <stdio.h>
int c;
//a{n} = -6a{n-1} -9a{n-2}, a{1}=1, a{2}=2(再帰あり版)
int rec(int n){
c++;
if(n==1){
return 1;
}
else if(n==2){
return 2;
}
else {
return -6*rec(n-1)-9*rec(n-2);
}
}
int main(void) {
int n = 5;
printf("数列a%dの値は%d \n", n
, rec
(n
)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CmludCBjOwovL2F7bn0gPSAtNmF7bi0xfSAtOWF7bi0yfSwgYXsxfT0xLCBhezJ9PTIo5YaN5biw44GC44KK54mIKQppbnQgcmVjKGludCBuKXsKCWMrKzsKCWlmKG49PTEpewoJCXJldHVybiAxOwoJfQoJZWxzZSBpZihuPT0yKXsKCQlyZXR1cm4gMjsKCX0KCWVsc2UgewoJCXJldHVybiAtNipyZWMobi0xKS05KnJlYyhuLTIpOwoJfQp9CgppbnQgbWFpbih2b2lkKSB7CiAgICBpbnQgbiA9IDU7CiAgICBwcmludGYoIuaVsOWIl2ElZOOBruWApOOBryVkIFxuIiwgbiwgcmVjKG4pKTsKICAgIHByaW50ZigieW9idWthaXN1dWhhICVkIixjKTsKCXJldHVybiAwOwp9Cgo=