Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int fibonacciRec(int numero){
  6.     if(numero == 1){
  7.         return 1;
  8.     }
  9.     if(numero == 0){
  10.         return 0;
  11.     }
  12.     return fibonacciRec(numero - 1) + fibonacciRec(numero -2);
  13. }
  14.  
  15. int main (){
  16.    
  17.     clock_t tiempo_inicio, tiempo_final;
  18.     double segundos;
  19.    
  20.     int num;
  21.    
  22.     printf("Ingresar un número: ");
  23.     scanf("%d",&num);
  24.     tiempo_inicio = clock();
  25.     printf("El resultado de el fibonacci(%d) es : %d \n", num, fibonacciRec(num));
  26.    
  27.     tiempo_final = clock();
  28.     segundos = (double)(tiempo_final - tiempo_inicio) / CLOCKS_PER_SEC;
  29.     printf("%f\n",segundos);
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement