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