Created
June 9, 2017 06:50
-
-
Save samba2/ec213974cfbfdaa35e270309aa37428b to your computer and use it in GitHub Desktop.
Recursive Calculation Of The Fibonacci Sequence Of a Given Number
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> | |
int fibbonacci(int n) { | |
if(n == 0) { | |
return 0; | |
} else if(n == 1) { | |
return 1; | |
} else { | |
return (fibbonacci(n-1) + fibbonacci(n-2)); | |
} | |
} | |
main() { | |
int n = 5; | |
printf("Fibbonacci of %d: " , n); | |
for(int i = 0;i<n;i++) { | |
printf("%d ",fibbonacci(i)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment