-
-
Save flavioribeiro/3334526 to your computer and use it in GitHub Desktop.
Fibonnaci in C for dailykata.net
This file contains hidden or 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
// 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