fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int i;
  5. int a = 0, b = 1, temp;
  6.  
  7. printf("0から30番目までのフィボナッチ数列:\n");
  8. for (i = 0; i <= 30; i++) {
  9. printf("%d\n", a);
  10. temp = a + b;
  11. a = b;
  12. b = temp;
  13. }
  14.  
  15. return 0;
  16. }
  17.  
  18.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
0から30番目までのフィボナッチ数列:
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040