fork download
  1. #include <stdio.h>
  2. //a{n+1} = -2a{n} + 4, a{0}=2(再帰なし版)
  3. int main(void) {
  4. int n = 4;
  5. int an=2;
  6. for(int i=0;i<n;i++){
  7. an=-2*an+4;
  8. } printf("数列a%dの値は%d\n", n, an);
  9.  
  10. return 0;
  11. }
  12.  
  13.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
数列a4の値は12