-
-
Save mina86/279048 to your computer and use it in GitHub Desktop.
This file contains 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
#include <stdio.h> | |
static unsigned long count; | |
static unsigned long fib(unsigned n) { | |
++count; | |
return n > 1 ? fib(n - 1) + fib(n - 2) : n; | |
} | |
int main(void) { | |
unsigned i; | |
for (i = 0; i < 36; ++i) { | |
unsigned long ans; | |
count = 0; | |
ans = fib(i); | |
printf("%2u: %10u (%10u calls)\n", i, ans, count); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment