Advertisement
CotaIgnorada

recursividad

Nov 5th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.   int fibonacci(int n){
  4.       if(n==1|| n==0){
  5.       return 1;
  6.       }
  7.       else
  8.           return fibonacci(n-1)+ fibonacci(n-2);
  9.       }
  10.  
  11.   int main(){
  12.       int resultado;
  13.       int numero;
  14.       printf("Introduzca un numero\n");
  15.       scanf("%d", &numero);
  16.       resultado = fibonacci(numero);
  17.       printf("resultado: %d\n", resultado);
  18.       return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement