Created
November 9, 2011 06:09
-
-
Save pedromtavares/1350575 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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