Skip to content

Instantly share code, notes, and snippets.

@jbochi
Created August 12, 2012 13:02
Show Gist options
  • Save jbochi/3331737 to your computer and use it in GitHub Desktop.
Save jbochi/3331737 to your computer and use it in GitHub Desktop.
Fibonnaci in C for dailykata.net
#include <stdio.h>;
int fib(int n) {
if (n == 1) {
return 1;
} else if (n == 0) {
return 0;
} 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