Advertisement
DimasDark

L0Q1 Fixed

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