Advertisement
DimasDark

L0Q1

May 23rd, 2013
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int _contador = 0;
  5.  
  6. int fibonacci(int n){
  7.     _contador++;
  8.     if( n== 0 || n == 1) return 1;
  9.     int retorno = fibonacci(n-1) + fibonacci(n-2);
  10.     return retorno;
  11. }
  12.  
  13. int main()
  14. {
  15. char linha[2];
  16.  
  17. freopen("L0Q1.in", "r", stdin);
  18.  
  19. freopen("L0Q1.out", "w", stdout);
  20.  
  21.  
  22.  
  23. while (scanf("%s", linha) != EOF) {
  24.     _contador = 0;
  25.     fibonacci(atoi(linha));
  26.     printf("%d\n", _contador);
  27.  
  28. }
  29.  
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement