Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int _contador = 0;
- int fibonacci(int n){
- _contador++;
- if( n== 0 || n == 1) return 1;
- int retorno = fibonacci(n-1) + fibonacci(n-2);
- return retorno;
- }
- int main()
- {
- char linha[2];
- freopen("L0Q1.in", "r", stdin);
- freopen("L0Q1.out", "w", stdout);
- while (scanf("%s", linha) != EOF) {
- _contador = 0;
- fibonacci(atoi(linha));
- printf("%d\n", _contador);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement