#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;
printf("数列a%dの値は%d\n", n
, rec
(n
)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Ci8vYXtuKzF9ID0gLTJhe259ICsgNCwgYXswfT0yKOWGjeW4sOOBguOCiueJiCkKaW50IHJlYyhpbnQgbil7CglpZihuPT0wKXsKCQlyZXR1cm4gMjsKfWVsc2UgewoJCQlyZXR1cm4gLTIqcmVjKG4tMSkrNDsKCQl9Cgl9CgoKaW50IG1haW4odm9pZCkgewogICAgaW50IG47CiAgICBzY2FuZigiJWQiLCZuKTsKICAgIHByaW50Zigi5pWw5YiXYSVk44Gu5YCk44GvJWRcbiIsIG4sIHJlYyhuKSk7CiAgIAlyZXR1cm4gMDsKfQoK