#include <stdio.h>
//a{n+1} = -2a{n} + 4, a{0}=2(再帰なし版)
int kannsuu(int n){
int an = 2;
for (int i=0;i<n;i++){
an = -2*an+4;
}
return an;
}
int main (void){
int n = 4;
printf("数列a%dの値は%d\n",n
,kannsuu
(n
)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Ci8vYXtuKzF9ID0gLTJhe259ICsgNCwgYXswfT0yKOWGjeW4sOOBquOBl+eJiCkKaW50IGthbm5zdXUoaW50IG4pewoJaW50IGFuID0gMjsKCWZvciAoaW50IGk9MDtpPG47aSsrKXsKCQlhbiA9IC0yKmFuKzQ7Cgl9CglyZXR1cm4gYW47Cn0KCmludCBtYWluICh2b2lkKXsKCWludCBuID0gNDsKCXByaW50Zigi5pWw5YiXYSVk44Gu5YCk44GvJWRcbiIsbixrYW5uc3V1KG4pKTsKCXJldHVybiAwOwp9CgoK