fork download
  1. #include <stdio.h>
  2. //フィボナッチ数列(再帰なし版)
  3. int main(void) {
  4. int n = 10;
  5. //ここを埋める
  6. int a,b=2;
  7. int c=1;
  8. for(int i = 3; i <= n; i++){
  9. //ここも埋める
  10. a=-6*b-9*c;
  11. c=b;
  12. b=a;
  13.  
  14. }
  15. printf("フィボナッチ数列の第%d項は%d\n", n, a);
  16. return 0;
  17. }
  18.  
  19.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
フィボナッチ数列の第10項は275562