[ create a new paste ] login | about

Link: http://codepad.org/G0vV3CfP    [ raw code | output | fork ]

C, pasted on Mar 8:
1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>

int fib(int n) {
    return n == 0 || n == 1 ? n : fib(n - 1) + fib(n - 2);
}

int main(void) {
    int i = 39; // 40 Timeout
    printf("fib(%d)=%d\n", i, fib(i));
    return 0;
}


Output:
1
2
fib(39)=63245986



Create a new paste based on this one


Comments: