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
unsigned long fibo_TopDown(int a, unsigned long* ptr){ | |
if(a==1) | |
{ | |
ptr[1]=1; | |
return ptr[1]; | |
} | |
else if(a==2) | |
{ | |
ptr[2]=1; | |
return ptr[2]; |
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
void fibo_BottomUp(int a, unsigned long* ptr){ | |
ptr[1] = 1; | |
ptr[2] = 1; | |
if(a>3) | |
{ | |
for(int i=3; i<=a; i++) | |
{ | |
ptr[i] = ptr[i-1] + ptr[i-2]; |
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
unsigned long fibo(int a){ | |
if (a==1 || a==2) | |
return 1; | |
else | |
return (fibo(a-1) + fibo(a-2)); | |
} |