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