Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int fibonacciRec(int numero){
- if(numero == 1){
- return 1;
- }
- if(numero == 0){
- return 0;
- }
- return fibonacciRec(numero - 1) + fibonacciRec(numero -2);
- }
- int main (){
- clock_t tiempo_inicio, tiempo_final;
- double segundos;
- int num;
- printf("Ingresar un número: ");
- scanf("%d",&num);
- tiempo_inicio = clock();
- printf("El resultado de el fibonacci(%d) es : %d \n", num, fibonacciRec(num));
- tiempo_final = clock();
- segundos = (double)(tiempo_final - tiempo_inicio) / CLOCKS_PER_SEC;
- printf("%f\n",segundos);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement