Skip to content

Instantly share code, notes, and snippets.

@wakhub
Created April 26, 2012 15:16
Show Gist options
  • Save wakhub/2500301 to your computer and use it in GitHub Desktop.
Save wakhub/2500301 to your computer and use it in GitHub Desktop.
C and konoha fibonacci
#include <stdio.h>
int fib(int n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
int main(){
int i;
for (i = 0; i < 20; i++) {
printf("%d\n", fib(i));
}
}
int fib(int n) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
for (i = 0; i < 20; i++) {
print fib(i);
}
@wakhub
Copy link
Author

wakhub commented Apr 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment