fork download
  1. #include <stdio.h>
  2.  
  3. char *input_1 = "11"; // al posto di argv[1];
  4.  
  5. unsigned int
  6. fibonacci (unsigned int n)
  7. {
  8. unsigned int f1 = 1;
  9. unsigned int f0 = 0;
  10. unsigned int fn = n;
  11. unsigned int i;
  12.  
  13. for (i = 2; i <= n; i++)
  14. {
  15. fn = f1 + f0;
  16. f0 = f1;
  17. f1 = fn;
  18. }
  19.  
  20. return fn;
  21. }
  22.  
  23. int
  24. main (int argc, char *argv[])
  25. {
  26. unsigned int n;
  27. unsigned int i;
  28.  
  29. sscanf (input_1, "%u", &n);
  30.  
  31. for (i = 0; i <= n; i++)
  32. {
  33. printf ("%u ", fibonacci (i));
  34. }
  35. printf ("\n");
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
0 1 1 2 3 5 8 13 21 34 55 89