Skip to content

Instantly share code, notes, and snippets.

@flavioribeiro
Forked from jbochi/gist:3331737
Created August 12, 2012 21:16
Show Gist options
  • Save flavioribeiro/3334526 to your computer and use it in GitHub Desktop.
Save flavioribeiro/3334526 to your computer and use it in GitHub Desktop.
Fibonnaci in C for dailykata.net
// just a small mod in @jbochi's solution
#include <stdio.h>;
int fib(int n) {
if (n < 2) {
return n;
} else {
return fib(n - 1) + fib(n - 2);
}
}
int main() {
int i;
for (i = 0; i < 10; i++) {
printf("fib %d: %d\n", i, fib(i));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment