Skip to content

Instantly share code, notes, and snippets.

@samba2
Created June 9, 2017 06:50
Show Gist options
  • Save samba2/ec213974cfbfdaa35e270309aa37428b to your computer and use it in GitHub Desktop.
Save samba2/ec213974cfbfdaa35e270309aa37428b to your computer and use it in GitHub Desktop.
Recursive Calculation Of The Fibonacci Sequence Of a Given Number
#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