Skip to content

Instantly share code, notes, and snippets.

@pedromtavares
Created November 9, 2011 06:09
Show Gist options
  • Save pedromtavares/1350575 to your computer and use it in GitHub Desktop.
Save pedromtavares/1350575 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define TAMANHO 10
long fibonacci(long);
main (){
long i, resultado[TAMANHO];
for (i=0; i<=TAMANHO-1;i++)
resultado[i]=0;
for (i=0;i<=TAMANHO-1;i++){
resultado[i]=fibonacci(i);
printf ("%ld%10ld", i, resultado[i]);
}
system ("pause");
}
long fibonacci(long x){
if (x==1||x==2)
return x;
else
return fibonacci(x-1)+fibonacci(x-2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment