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. if (n == 0)
  9. {
  10. return 0;
  11. }
  12. else if (n == 1)
  13. {
  14. return 1;
  15. }
  16. else
  17. {
  18. return (fibonacci (n-1) + fibonacci (n-2));
  19. }
  20. }
  21.  
  22. int
  23. main (int argc, char *argv[])
  24. {
  25. unsigned int n;
  26. unsigned int i;
  27.  
  28. sscanf (input_1, "%u", &n);
  29.  
  30. for (i = 0; i <= n; i++)
  31. {
  32. printf ("%u ", fibonacci (i));
  33. }
  34. printf ("\n");
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
0 1 1 2 3 5 8 13 21 34 55 89