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. }
  9. printf("数列a%dの値は%d\n", n, an);
  10.  
  11. return 0;
  12. }
  13.  
  14.  
Success #stdin #stdout 0s 5272KB
stdin
Standard input is empty
stdout
数列a4の値は12